Bug 259895 - Shell close causes widget disposed error
Summary: Shell close causes widget disposed error
Status: RESOLVED FIXED
Alias: None
Product: SWTBot
Classification: Technology
Component: SWTBot (show other bugs)
Version: 2.0.0-dev   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 2.0.0   Edit
Assignee: Ketan Padegaonkar CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-03 14:38 EST by Ketan Patel CLA
Modified: 2009-01-04 14:45 EST (History)
0 users

See Also:
KetanPadegaonkar: iplog+


Attachments
mylyn/context/zip (3.11 KB, application/octet-stream)
2009-01-04 00:37 EST, Ketan Padegaonkar CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ketan Patel CLA 2009-01-03 14:38:54 EST
Build ID: 2.0

Steps To Reproduce:
I am seeing below exception when calling SWTBotShell.close();

2009/01/03 14:29:08.359 SEVERE Unhandled event loop exception ::class.method=unknown ::thread=main ::loggername=org.eclipse.ui

	org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)
	at org.eclipse.swt.SWT.error(Unknown Source)
	at org.eclipse.swt.SWT.error(Unknown Source)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Unknown Source)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Unknown Source)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Unknown Source)
	at org.eclipse.ui.internal.Workbench.runUI(Unknown Source)
	at org.eclipse.ui.internal.Workbench.access$4(Unknown Source)
	at org.eclipse.ui.internal.Workbench$5.run(Unknown Source)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Unknown Source)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Unknown Source)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(Unknown Source)
	at com.ibm.rcp.personality.framework.internal.RCPApplication.run(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(Unknown Source)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Unknown Source)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(Unknown Source)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(Unknown Source)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:387)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Caused by: org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.swt.SWT.error(Unknown Source)
	at org.eclipse.swt.SWT.error(Unknown Source)
	at org.eclipse.swt.SWT.error(Unknown Source)
	at org.eclipse.swt.widgets.Widget.error(Unknown Source)
	at org.eclipse.swt.widgets.Widget.checkWidget(Unknown Source)
	at org.eclipse.swt.widgets.Shell.close(Unknown Source)
	at net.sf.swtbot.widgets.SWTBotShell$2.run(SWTBotShell.java:85)
	at net.sf.swtbot.finder.UIThreadRunnable$5.doRun(UIThreadRunnable.java:238)
	at net.sf.swtbot.finder.UIThreadRunnable$1.run(UIThreadRunnable.java:88)
	at org.eclipse.swt.widgets.RunnableLock.run(Unknown Source)
	... 29 more

More information:
The problem seems to be that there is a notify sent and then asyn execution of close which is causing the exception. There should be a check to see that widget is not disposed before calling close.

	notify(SWT.Close);
	asyncExec(new VoidResult() {
		public void run() {
			widget.close();
		}
	});
Comment 1 Ketan Padegaonkar CLA 2009-01-04 00:31:03 EST
Fixed in trunk by adding a guard condition. Although I'm not very sure as to why the notification itself is disposing the shell.

Is there a SWT.Close listener that is disposing the shell ? Please verify and mark as closed.
Comment 2 Ketan Padegaonkar CLA 2009-01-04 00:37:30 EST
Created attachment 121478 [details]
mylyn/context/zip
Comment 3 Ketan Patel CLA 2009-01-04 12:43:13 EST
I debugged this little more and noticed that it happens with ContentAssist shell.  It adds hooks for lots of events and I noticed that notify event is closing the shell.   
Comment 4 Ketan Patel CLA 2009-01-04 12:47:39 EST
Just found the class which is closing the shell on SWT.Close...it is in the org.eclipse.jface.text.contentassist.PopupCloser, which has shellClosed method registered to SWT.Close event.
Comment 5 Ketan Padegaonkar CLA 2009-01-04 14:05:47 EST
I think that should be fine.

A guard condition would not hurt, although the PopupCloser should probably not be closing the shell from within a shellClosed event. You should probably file a bug against JFace for this offense :)

Comment 6 Ketan Patel CLA 2009-01-04 14:45:43 EST
I don't know if it is a bug in JFace because looking at Shell close method...all it does is sends SWT.Close event.

public void close () {
	checkWidget ();
	closeWidget ();
}
void closeWidget () {
	Event event = new Event ();
	sendEvent (SWT.Close, event);
	if (event.doit && !isDisposed ()) dispose ();
}

(In reply to comment #5)
> I think that should be fine.
> 
> A guard condition would not hurt, although the PopupCloser should probably not
> be closing the shell from within a shellClosed event. You should probably file
> a bug against JFace for this offense :)
>