Project: SWT
Bug 255282 SWTException thrown from CCombo
Reported: 2008-11-13 17:29:01 | Status: resolved fixed

The ingredients are: 1. A CCombo widget. 2. This CCombo widget added to an Eclipse View. 3. The View has to be detached (this is important as it triggers the exception). The steps to reproduce are: 1. Open the View (detached) containing the CCombo widget. 2. Activite the CCombo by selecting an item from it. 3. Close the (detached) View ensuring that the focus is still on the CCombo widget. 4. Repeat steps 1-2 but this time selecting an item from the CCombo throws an exception: !MESSAGE Unhandled event loop exception !STACK 0 org.eclipse.swt.SWTException: Widget is disposed at org.eclipse.swt.SWT.error(SWT.java:3777) at org.eclipse.swt.SWT.error(SWT.java:3695) at org.eclipse.swt.SWT.error(SWT.java:3666) at org.eclipse.swt.widgets.Widget.error(Widget.java:463) at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:336) at org.eclipse.swt.widgets.Control.getShell(Control.java:1398) at org.eclipse.swt.custom.CCombo$1.handleEvent(CCombo.java:121) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1008) at org.eclipse.swt.widgets.Decorations.WM_ACTIVATE(Decorations.java:1625) at org.eclipse.swt.widgets.Shell.WM_ACTIVATE(Shell.java:2013) at org.eclipse.swt.widgets.Control.windowProc(Control.java:3784) at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337) at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1576) at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1937) at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528) at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method) at org.eclipse.swt.widgets.Control.forceFocus(Control.java:974) at org.eclipse.swt.widgets.Control.setFocus(Control.java:2811) at org.eclipse.swt.custom.CCombo.dropDown(CCombo.java:538) at org.eclipse.swt.custom.CCombo.arrowEvent(CCombo.java:317) at org.eclipse.swt.custom.CCombo$1.handleEvent(CCombo.java:114) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.tencompetence.ldauthor.LDAuthorApp.start(LDAuthorApp.java:80) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:386) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) 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) My theory - it seems that the CCombo is not unregistering itself and still handling events from the Shell here: if (getShell () == event.widget) { getDisplay().asyncExec(new Runnable() { public void run() { if (isDisposed()) return; handleFocus (SWT.FocusOut); } }); } } But this only happens if: a). The Parent View is in a detached state AND b). The CCombo widget has the focus when closing the View.

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java