www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.dwt - ProgressMonitorDialog : Access Violation

reply yidabu <yidabu.spam gmail.com> writes:
jface ProgressMonitorDialog cause runtime Access Violation,
ddbg captured:

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at dwtx.jface.dialog
s.ProgressMonitorDialog.ProgressMonitorDialog.configureShell.dwt.widgets.Shell.S
hell.__anonclass95.handleEvent.dwt.widgets.Event.Event.__anonclass96.run (0x0040
d890) thread(3412)

tested with dwt-win svn, dwtx svn, dmd 1.028

Example code:


import dwt.DWT;
import dwt.layout.FillLayout;
import dwt.widgets.Display;
import dwt.widgets.Shell;
import dwt.widgets.Listener;
import dwt.widgets.Event;
import dwt.widgets.Button;

import dwtx.jface.dialogs.PopupDialog;
import dwt.dwthelper.utils;

import dwtx.jface.dialogs.ProgressMonitorDialog;
import dwtx.core.runtime.IProgressMonitor;
import dwtx.jface.operation.IRunnableWithProgress;

import tango.core.Thread;


void handleSelection(Event e, Shell shell)
{

    void run(IProgressMonitor monitor)
    {
        monitor.beginTask("generate", 30);
        for(int i=0; i<100; i++)
        {
            if(monitor.isCanceled())
            {
                return;
            }
            monitor.worked(1);
            Thread.sleep(50);
        }
        monitor.done();
    }

    auto dialog = new ProgressMonitorDialog(shell);
    dialog.run(true, true, dgIRunnableWithProgress(&run));

}

void main() {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    Button button = new Button(shell, DWT.PUSH);
    button.setText("&OK");

    button.addListener(DWT.Selection, dgListener(&handleSelection, shell));

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
}

-- 
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/
Jun 20 2008
parent reply Frank Benoit <keinfarbton googlemail.com> writes:
yidabu schrieb:
 jface ProgressMonitorDialog cause runtime Access Violation,
 ddbg captured:
 
 Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at
dwtx.jface.dialog
 s.ProgressMonitorDialog.ProgressMonitorDialog.configureShell.dwt.widgets.Shell.S
 hell.__anonclass95.handleEvent.dwt.widgets.Event.Event.__anonclass96.run
(0x0040
 d890) thread(3412)
 
 tested with dwt-win svn, dwtx svn, dmd 1.028
 
 Example code:
 
 
 import dwt.DWT;
 import dwt.layout.FillLayout;
 import dwt.widgets.Display;
 import dwt.widgets.Shell;
 import dwt.widgets.Listener;
 import dwt.widgets.Event;
 import dwt.widgets.Button;
 
 import dwtx.jface.dialogs.PopupDialog;
 import dwt.dwthelper.utils;
 
 import dwtx.jface.dialogs.ProgressMonitorDialog;
 import dwtx.core.runtime.IProgressMonitor;
 import dwtx.jface.operation.IRunnableWithProgress;
 
 import tango.core.Thread;
 
 
 void handleSelection(Event e, Shell shell)
 {
 
     void run(IProgressMonitor monitor)
     {
         monitor.beginTask("generate", 30);
         for(int i=0; i<100; i++)
         {
             if(monitor.isCanceled())
             {
                 return;
             }
             monitor.worked(1);
             Thread.sleep(50);
         }
         monitor.done();
     }
 
     auto dialog = new ProgressMonitorDialog(shell);
     dialog.run(true, true, dgIRunnableWithProgress(&run));
 
 }
 
 void main() {
     final Display display = new Display();
     final Shell shell = new Shell(display);
     shell.setLayout(new FillLayout());
     Button button = new Button(shell, DWT.PUSH);
     button.setText("&OK");
 
     button.addListener(DWT.Selection, dgListener(&handleSelection, shell));
 
     shell.pack();
     shell.open();
     while (!shell.isDisposed()) {
         if (!display.readAndDispatch()) display.sleep();
     }
     display.dispose();
 }
 
Thanks for the report yidabu. It is fixed now. In your example code, i noticed this: Thread.sleep(50); // should be 0.050
Jun 20 2008
parent reply yidabu <yidabu.spam gmail.com> writes:
On Fri, 20 Jun 2008 13:02:06 +0200
Frank Benoit <keinfarbton googlemail.com> wrote:

 yidabu schrieb:
 jface ProgressMonitorDialog cause runtime Access Violation,
 ddbg captured:
 
 Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at
dwtx.jface.dialog
 s.ProgressMonitorDialog.ProgressMonitorDialog.configureShell.dwt.widgets.Shell.S
 hell.__anonclass95.handleEvent.dwt.widgets.Event.Event.__anonclass96.run
(0x0040
 d890) thread(3412)
 
 tested with dwt-win svn, dwtx svn, dmd 1.028
 
 Thanks for the report yidabu.
 It is fixed now.
 In your example code, i noticed this:
 Thread.sleep(50); // should be 0.050
update to svn, still not work: runtime exception: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at dwtx.jface.dialog s.ProgressMonitorDialog.ProgressMonitorDialog.setMessage (0x0040dc1a) thread(266 8) ->us e(char[], bool, void*) () at DwtTest.d:42 from ProgressMonitorDialog alog.configureShell(class dwt.widgets.Shell.Shell, void*) . void __anonclass94.h andleEvent(class dwt.widgets.Event.Event, void*) . void __anonclass95.run(void*) () at DwtTest.d:42 from ProgressMonitorDialog l, void*) () at DwtTest.d:42 from Synchronizer () at DwtTest.d:42 from Display tThread.block(void*) () at DwtTest.d:42 from ModalContext wtx.jface.operation.IRunnableWithProgress.IRunnableWithProgress, bool, class dwt x.core.runtime.IProgressMonitor.IProgressMonitor, class dwt.widgets.Display.Disp lay) () at DwtTest.d:42 from ModalContext alog.run(bool, bool, class dwtx.jface.operation.IRunnableWithProgress.IRunnableW ithProgress, void*) () at DwtTest.d:42 from ProgressMonitorDialog Test.obj ets.Event.Event, void*) () at DwtTest.d:60 from EventTable -- 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/
Jun 20 2008
parent reply Frank Benoit <keinfarbton googlemail.com> writes:
yidabu schrieb:
 On Fri, 20 Jun 2008 13:02:06 +0200
 Frank Benoit <keinfarbton googlemail.com> wrote:
 
 yidabu schrieb:
 jface ProgressMonitorDialog cause runtime Access Violation,
 ddbg captured:

 Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at
dwtx.jface.dialog
 s.ProgressMonitorDialog.ProgressMonitorDialog.configureShell.dwt.widgets.Shell.S
 hell.__anonclass95.handleEvent.dwt.widgets.Event.Event.__anonclass96.run
(0x0040
 d890) thread(3412)

 tested with dwt-win svn, dwtx svn, dmd 1.028
 Thanks for the report yidabu.
 It is fixed now.
 In your example code, i noticed this:
 Thread.sleep(50); // should be 0.050
update to svn, still not work: ...
strange. I tested it on linux and windows. are you sure you updated dwt-addons? this was the fix: http://www.dsource.org/projects/dwt-addons/changeset/83%3A028aedd523ad
Jun 20 2008
next sibling parent reply yidabu <yidabu.spam gmail.com> writes:
On Sat, 21 Jun 2008 01:49:56 +0200
Frank Benoit <keinfarbton googlemail.com> wrote:

 yidabu schrieb:
 On Fri, 20 Jun 2008 13:02:06 +0200
 Frank Benoit <keinfarbton googlemail.com> wrote:
 
 yidabu schrieb:
 jface ProgressMonitorDialog cause runtime Access Violation,
 ddbg captured:

 Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at
dwtx.jface.dialog
 s.ProgressMonitorDialog.ProgressMonitorDialog.configureShell.dwt.widgets.Shell.S
 hell.__anonclass95.handleEvent.dwt.widgets.Event.Event.__anonclass96.run
(0x0040
 d890) thread(3412)

 tested with dwt-win svn, dwtx svn, dmd 1.028
 Thanks for the report yidabu.
 It is fixed now.
 In your example code, i noticed this:
 Thread.sleep(50); // should be 0.050
update to svn, still not work: ...
strange. I tested it on linux and windows. are you sure you updated dwt-addons? this was the fix: http://www.dsource.org/projects/dwt-addons/changeset/83%3A028aedd523ad
perhaps the issue is I have not add -full to dsss buildflags to build a static dwtx.lib. now I rebuild dwtx.lib, it may take two hours. -- 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/
Jun 20 2008
parent reply yidabu <yidabu.spam gmail.com> writes:
 Thanks for the report yidabu.
 It is fixed now.
 In your example code, i noticed this:
 Thread.sleep(50); // should be 0.050
update to svn, still not work: ...
strange. I tested it on linux and windows. are you sure you updated dwt-addons? this was the fix: http://www.dsource.org/projects/dwt-addons/changeset/83%3A028aedd523ad
perhaps the issue is I have not add -full to dsss buildflags to build a static dwtx.lib. now I rebuild dwtx.lib, it may take two hours.
added -full dsss buildflag and got a new dwtx.lib, but get same object.Exception: Access Violation should remove dsss_objs and dsss_imports directory first to build dwtx.lib ? -- 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/
Jun 20 2008
parent yidabu <yidabu.spam gmail.com> writes:
On Sat, 21 Jun 2008 08:52:30 +0800
yidabu <yidabu.spam gmail.com> wrote:

 
 Thanks for the report yidabu.
 It is fixed now.
 In your example code, i noticed this:
 Thread.sleep(50); // should be 0.050
update to svn, still not work: ...
strange. I tested it on linux and windows. are you sure you updated dwt-addons? this was the fix: http://www.dsource.org/projects/dwt-addons/changeset/83%3A028aedd523ad
perhaps the issue is I have not add -full to dsss buildflags to build a static dwtx.lib. now I rebuild dwtx.lib, it may take two hours.
added -full dsss buildflag and got a new dwtx.lib, but get same object.Exception: Access Violation should remove dsss_objs and dsss_imports directory first to build dwtx.lib ?
dsss_objs and dsss_imports removed, but still not work I'm no idea that why PopupDialog works but rogressMonitorDialog failed after update to svn. -- 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/
Jun 20 2008
prev sibling parent reply yidabu <yidabu.spam gmail.com> writes:
 tested with dwt-win svn, dwtx svn, dmd 1.028
 Thanks for the report yidabu.
 It is fixed now.
 In your example code, i noticed this:
 Thread.sleep(50); // should be 0.050
update to svn, still not work: ...
strange. I tested it on linux and windows. are you sure you updated dwt-addons? this was the fix: http://www.dsource.org/projects/dwt-addons/changeset/83%3A028aedd523ad
change : dialog.run(true, true, dgIRunnableWithProgress(&run)); to: dialog.run(false, true, dgIRunnableWithProgress(&run)); Progress bar worked, and after monitor.done(), cause Exception: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at dwtx.jface.dialog s.ProgressMonitorDialog.ProgressMonitorDialog.configureShell.dwt.widgets.Shell.S hell.__anonclass94.handleEvent.dwt.widgets.Event.Event.__anonclass95.run (0x0040 d891) thread(2004) seems it's another anonclass problem. -- 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/
Jun 20 2008
parent reply Frank Benoit <keinfarbton googlemail.com> writes:
yidabu schrieb:
 tested with dwt-win svn, dwtx svn, dmd 1.028
Thanks for the report yidabu. It is fixed now. In your example code, i noticed this: Thread.sleep(50); // should be 0.050
update to svn, still not work: ...
strange. I tested it on linux and windows. are you sure you updated dwt-addons? this was the fix: http://www.dsource.org/projects/dwt-addons/changeset/83%3A028aedd523ad
change : dialog.run(true, true, dgIRunnableWithProgress(&run)); to: dialog.run(false, true, dgIRunnableWithProgress(&run)); Progress bar worked, and after monitor.done(), cause Exception: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at dwtx.jface.dialog s.ProgressMonitorDialog.ProgressMonitorDialog.configureShell.dwt.widgets.Shell.S hell.__anonclass94.handleEvent.dwt.widgets.Event.Event.__anonclass95.run (0x0040 d891) thread(2004) seems it's another anonclass problem.
i had tested it with dmd 1.031 ... and indeed with dmd 1.028 it crashes. Your first example code should work now. With the
 dialog.run(false, true, dgIRunnableWithProgress(&run));
there is still a problem :/
Jun 21 2008
parent reply Frank Benoit <keinfarbton googlemail.com> writes:
Frank Benoit schrieb:
 i had tested it with dmd 1.031 ... and indeed with dmd 1.028 it crashes.
 Your first example code should work now.
 With the
  > dialog.run(false, true, dgIRunnableWithProgress(&run));
 there is still a problem :/
Now it works with fork=false, but another anon class workaround was necessary. Also a fix in the example code is needed to make fork=false work. From the ProgressMonitorDialog doc: If fork is set to false, the runnable will run in the UI thread and it is the runnable's responsibility to call Display.readAndDispatch() to ensure UI responsiveness. The example code looks now like this: import dwt.DWT; import dwt.layout.FillLayout; import dwt.widgets.Display; import dwt.widgets.Shell; import dwt.widgets.Listener; import dwt.widgets.Event; import dwt.widgets.Button; import dwtx.jface.dialogs.PopupDialog; import dwt.dwthelper.utils; import dwtx.jface.dialogs.ProgressMonitorDialog; import dwtx.core.runtime.IProgressMonitor; import dwtx.jface.operation.IRunnableWithProgress; import tango.core.Thread; version=NOFORK; void handleSelection(Event e, Shell shell) { void run(IProgressMonitor monitor) { monitor.beginTask("generate", 30); for(int i=0; i<100; i++) { if(monitor.isCanceled()) { return; } monitor.worked(1); Thread.sleep(0.050); version(NOFORK) Display.getCurrent().readAndDispatch(); } monitor.done(); version(NOFORK) Display.getCurrent().readAndDispatch(); } auto dialog = new ProgressMonitorDialog(shell); version(NOFORK) { dialog.run(false, true, dgIRunnableWithProgress(&run)); } else { dialog.run(true, true, dgIRunnableWithProgress(&run)); } } void main() { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Button button = new Button(shell, DWT.PUSH); button.setText("&OK"); button.addListener(DWT.Selection, dgListener(&handleSelection, shell)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
Jun 21 2008
parent yidabu <yidabu.spam gmail.com> writes:
On Sat, 21 Jun 2008 15:35:33 +0200
Frank Benoit <keinfarbton googlemail.com> wrote:

 Frank Benoit schrieb:
 i had tested it with dmd 1.031 ... and indeed with dmd 1.028 it crashes.
 Your first example code should work now.
 With the
  > dialog.run(false, true, dgIRunnableWithProgress(&run));
 there is still a problem :/
Now it works with fork=false, but another anon class workaround was necessary. Also a fix in the example code is needed to make fork=false work. From the ProgressMonitorDialog doc: If fork is set to false, the runnable will run in the UI thread and it is the runnable's responsibility to call Display.readAndDispatch() to ensure UI responsiveness. The example code looks now like this: import dwt.DWT; import dwt.layout.FillLayout; import dwt.widgets.Display; import dwt.widgets.Shell; import dwt.widgets.Listener; import dwt.widgets.Event; import dwt.widgets.Button; import dwtx.jface.dialogs.PopupDialog; import dwt.dwthelper.utils; import dwtx.jface.dialogs.ProgressMonitorDialog; import dwtx.core.runtime.IProgressMonitor; import dwtx.jface.operation.IRunnableWithProgress; import tango.core.Thread; version=NOFORK; void handleSelection(Event e, Shell shell) { void run(IProgressMonitor monitor) { monitor.beginTask("generate", 30); for(int i=0; i<100; i++) { if(monitor.isCanceled()) { return; } monitor.worked(1); Thread.sleep(0.050); version(NOFORK) Display.getCurrent().readAndDispatch(); } monitor.done(); version(NOFORK) Display.getCurrent().readAndDispatch(); } auto dialog = new ProgressMonitorDialog(shell); version(NOFORK) { dialog.run(false, true, dgIRunnableWithProgress(&run)); } else { dialog.run(true, true, dgIRunnableWithProgress(&run)); } } void main() { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Button button = new Button(shell, DWT.PUSH); button.setText("&OK"); button.addListener(DWT.Selection, dgListener(&handleSelection, shell)); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
thanks a lot! -- 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/
Jun 21 2008