www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - dwt-win Path bug with tango 0.99.7

reply yidabu <yidabu.spam gmail.com> writes:
theres is Break change in tango 0.99.7L
Backslashes ( \ ) are no longer accepted as in FilePath and PathParser - use
Path.standard before passing paths to them. 

for example,
dwtx.jface.preference.DirectoryFieldEditor

line 59:
auto f = new FilePath(getTextControl().getText());
sholud be:
auto f = new FilePath(Path.standard(getTextControl().getText()));

otherwise, fileDialog.setFilterPath(startingDirectory.path); will failure.

all modules imported FilePath or Path should do a check, my program crashed:
Exception occurred
Exception of type tango.core.Exception.IOException in (0): unexpected '\'
character in path: C:\Documents and Settings\Administrator\Application
Data\Software

I haven't found the issue this time.


-- 
yidabu <yidabu.spam gmail.com>
http://www.dsource.org/projects/dwin

D 语言-中文(D Chinese):
http://www.d-programming-language-china.org/
http://bbs.d-programming-language-china.org/
http://dwin.d-programming-language-china.org/
http://scite4d.d-programming-language-china.org/
Jul 30 2008
next sibling parent yidabu <yidabu.spam gmail.com> writes:
On Thu, 31 Jul 2008 10:27:38 +0800
yidabu <yidabu.spam gmail.com> wrote:

 
 theres is Break change in tango 0.99.7L
 Backslashes ( \ ) are no longer accepted as in FilePath and PathParser - use
Path.standard before passing paths to them. 
 
 for example,
 dwtx.jface.preference.DirectoryFieldEditor
 
 line 59:
 auto f = new FilePath(getTextControl().getText());
 sholud be:
 auto f = new FilePath(Path.standard(getTextControl().getText()));
 
 otherwise, fileDialog.setFilterPath(startingDirectory.path); will failure.
 
 all modules imported FilePath or Path should do a check, my program crashed:
 Exception occurred
 Exception of type tango.core.Exception.IOException in (0): unexpected '\'
character in path: C:\Documents and Settings\Administrator\Application
Data\Software
 
 I haven't found the issue this time.

modules that import FilePath: D:/d/dmd/src/dwt-addons/dwtx/jface/preference/DirectoryFieldEditor.d D:/d/dmd/src/dwt-addons/dwtx/jface/preference/FileFieldEditor.d D:/d/dmd/src/dwt-addons/dwtx/jface/preference/PathEditor.d D:/d/dmd/src/dwt-win/dwt/dwthelper/File.d -- yidabu <yidabu.spam gmail.com> http://www.dsource.org/projects/dwin D 语言-中文(D Chinese): http://www.d-programming-language-china.org/ http://bbs.d-programming-language-china.org/ http://dwin.d-programming-language-china.org/ http://scite4d.d-programming-language-china.org/
Jul 30 2008
prev sibling parent yidabu <yidabu.spam gmail.com> writes:
runtime exception:

Exception occurred
Exception of type tango.core.Exception.IOException in (0): unexpected '\'
character in path: C:\Documents and Settings\Owner\My Documents

ddbg captured:

(tango.core.Exception.IOException
 "<console> :: The handle is invalid.") at KERNEL32.dll (0x7c812a5b)
thread(2276)
->us
#0 ?? () from KERNEL32.dll
->


Example code (based on ShowFieldPrefs.d):


import dwtx.jface.preference.DirectoryFieldEditor;
import dwtx.jface.preference.FileFieldEditor;
import dwtx.jface.preference.FieldEditorPreferencePage;
import dwtx.jface.preference.PathEditor;
import dwtx.jface.preference.StringFieldEditor;
import dwtx.jface.preference.IPreferenceStore;
import dwtx.jface.preference.PreferenceManager;
import dwtx.jface.preference.PreferencePage;
import dwtx.jface.preference.PreferenceNode;
import dwtx.jface.preference.PreferenceStore;
import dwtx.jface.preference.PreferenceDialog;
import dwtx.jface.resource.ImageDescriptor;

import dwt.widgets.Display;
import dwt.widgets.Composite;
import dwt.widgets.Label;
import dwt.widgets.Button;
import dwt.widgets.Text;
import dwt.widgets.Control;
import dwt.events.SelectionAdapter;
import dwt.events.SelectionEvent;
import dwt.layout.RowLayout;
import dwt.layout.GridLayout;
import dwt.layout.GridData;
import dwt.DWT;
import dwt.dwthelper.utils;

import tango.io.File;
import Path = tango.io.Path;

version(JIVE) import jive.stacktrace;

const char[] FILENAME = "showfieldprefs";

/**
 * This class demonstrates field editors
 */
public class FieldEditorPageOne : FieldEditorPreferencePage {
    public this() {
        // Use the "flat" layout
        super(FLAT);
    }

    /**
     * Creates the field editors
     */
    protected void createFieldEditors() {

        // Add a directory field
        DirectoryFieldEditor dfe = new DirectoryFieldEditor("myDirectory",
            "Directory:", getFieldEditorParent());
        addField(dfe);

        // Add a file field
        FileFieldEditor ffe = new FileFieldEditor("myFile", "File:",
            getFieldEditorParent());
        addField(ffe);

        // Add a path field
        PathEditor pe = new PathEditor("myPath", "Path:", "Choose a Path",
            getFieldEditorParent());
        addField(pe);
    }
}





/**
 * This class demonstrates JFace preferences and field editors
 */
public class ShowFieldPrefs {
    /**
    * Runs the application
    */
    public void run() {
//         Display display = new Display();

        // Create the preference manager
        PreferenceManager mgr = new PreferenceManager();

        // Create the nodes
        PreferenceNode one = new PreferenceNode("one", "One", null,
            FieldEditorPageOne.classinfo.name );


        // Add the nodes
        mgr.addToRoot(one);

        // Create the preferences dialog
        PreferenceDialog dlg = new PreferenceDialog(null, mgr);

        // Set the preference store
        PreferenceStore ps = new PreferenceStore(FILENAME);
        try {
            ps.load();
        } catch (IOException e) {
            // Ignore
        }
        dlg.setPreferenceStore(ps);

        // Open the dialog
        dlg.open();

        try {
            // Save the preferences
            ps.save();
        } catch (IOException e) {
            ExceptionPrintStackTrace(e);
        }
//         display.dispose();
    }

    /**
     * The application entry point
     *
     *  param args the command line arguments
     */
    public static void main(String[] args) {
        (new ShowFieldPrefs()).run();
    }
}


void main(){
    if( !Path.exists( FILENAME ) ){
        scope prefs = new File( FILENAME );
        version(linux){
            prefs.write( import("jface.showfieldprefs.properties.linux" ));
        }
        version(Windows){
            prefs.write( import("jface.showfieldprefs.properties.win" ));
        }
    }
    ShowFieldPrefs.main( null );
}










-- 
yidabu <yidabu.spam gmail.com>
http://www.dsource.org/projects/dwin

D 语言-中文(D Chinese):
http://www.d-programming-language-china.org/
http://bbs.d-programming-language-china.org/
http://dwin.d-programming-language-china.org/
http://scite4d.d-programming-language-china.org/
Jul 30 2008