Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 462467

Summary: Widget is disposed error if I run the Copy Build ID to clipboard
Product: [Eclipse Project] Platform Reporter: Lars Vogel <Lars.Vogel>
Component: UIAssignee: Platform-UI-Inbox <Platform-UI-Inbox>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: arunkumar.thondapu, bsd, daniel_megert, Lars.Vogel
Version: 4.5   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on: 433746    
Bug Blocks:    

Description Lars Vogel CLA 2015-03-18 10:18:00 EDT
To test Ctrl+3 -> Enter the "Copy Build ID to clipboard" command and you get the error from below in Build id: I20150317-2000.

Not sure if that is an SWT issue but I'm not aware any a change in our area which could result in this exception.

org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.swt.SWT.error(SWT.java:4481)
	at org.eclipse.swt.SWT.error(SWT.java:4396)
	at org.eclipse.swt.SWT.error(SWT.java:4367)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:477)
	at org.eclipse.swt.widgets.Widget.getDisplay(Widget.java:563)
	at org.eclipse.ui.internal.ide.commands.CopyBuildIdToClipboardHandler.execute(CopyBuildIdToClipboardHandler.java:40)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:247)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:229)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:343)
	at org.eclipse.ui.internal.quickaccess.CommandElement.execute(CommandElement.java:72)
	at org.eclipse.ui.internal.quickaccess.SearchField$2.handleElementSelected(SearchField.java:179)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.handleSelection(QuickAccessContents.java:460)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.access$0(QuickAccessContents.java:450)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents$1.keyPressed(QuickAccessContents.java:495)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:167)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4477)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1322)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1346)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1331)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1358)
	at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:758)
	at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:3309)
	at org.eclipse.swt.widgets.Text.gtk_key_press_event(Text.java:1805)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2020)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:5541)
	at org.eclipse.swt.widgets.Text.windowProc(Text.java:2758)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4707)
	at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:9205)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1250)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2421)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3423)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1112)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:993)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 1 Lars Vogel CLA 2015-03-18 10:23:32 EDT
After a restart of the Eclipse IDE, I'm not able to reproduce it anymore. Setting to worksforme.
Comment 2 Lars Vogel CLA 2015-04-28 14:56:57 EDT
Happens again regulary in Build id: N20150425-1500
Comment 3 Arun Thondapu CLA 2015-04-29 03:13:37 EDT
Verified it works for me on Ubuntu 12.04 and Ubuntu 14.04 with I20150428-0100. Please test with the latest I-build and confirm.
Comment 4 Lars Vogel CLA 2015-04-29 07:41:18 EDT
(In reply to Arun Thondapu from comment #3)
> Verified it works for me on Ubuntu 12.04 and Ubuntu 14.04 with
> I20150428-0100. Please test with the latest I-build and confirm.

I still get this error on a regular basis with Build id: I20150428-0100
Comment 5 Arun Thondapu CLA 2015-04-29 09:15:59 EDT
(In reply to Lars Vogel from comment #4)
> (In reply to Arun Thondapu from comment #3)
> > Verified it works for me on Ubuntu 12.04 and Ubuntu 14.04 with
> > I20150428-0100. Please test with the latest I-build and confirm.
> 
> I still get this error on a regular basis with Build id: I20150428-0100

I cannot investigate this further because no matter how many times I try it, it always works for me, so it looks like there is some prior sequence of events that is causing the exception in a particular scenario. Moreover, I don't even see how this can be fixed in SWT since the widget is somehow getting disposed from the UI code itself and needs to be handled there... assigning back to UI for further investigation.
Comment 6 Brian de Alwis CLA 2015-04-29 10:28:01 EDT
It sounds like a dupe of bug 433778 where the shell returned is the shell of the Quick Access drop-down, where it's sometimes disposed before the handler executes:

	clipboard = new Clipboard(HandlerUtil.getActiveShell(event)
		.getDisplay());

My guess is that the recent change to the Quick Access like bug 433746 or bug 449485 may have perturbed the execution context?

We can fix the immediate symptom with:

	clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());

The handler is still somewhat problematic in that it assumes it's executing on the SWT thread.
Comment 7 Brian de Alwis CLA 2015-04-29 10:44:41 EDT
It seems strange to me that we set the commandProvider's execution snapshot in SearchField's text #focusGained method.  Shouldn't this be done once, during the widget creation when the active shell is the window?
Comment 8 Brian de Alwis CLA 2015-04-29 11:05:27 EDT
(In reply to Brian de Alwis from comment #7)
> It seems strange to me that we set the commandProvider's execution snapshot
> in SearchField's text #focusGained method.  Shouldn't this be done once,
> during the widget creation when the active shell is the window?

Oops, of course this is the right place: we need to set the context when the user clicks into the search text field.

Aha, I think I have it: bug 433746 removed the shell-closed listener which called QuickAccessContents.doClose() which reset the different providers.  CommandProvider#reset() tossed the context snapshot.  Since the providers are now not being reset, the CommandProvider's context snapshot isn't being updated and so you're executing CBI with a stale context.
Comment 9 Dani Megert CLA 2015-04-30 08:16:30 EDT
Like Arun I cannot reproduce this and #doClose is actually called:

Thread [main] (Suspended (breakpoint at line 160 in SearchField$2))	
	owns: RunnableLock  (id=7519)	
	SearchField$2.doClose() line: 160	
	SearchField.checkFocusLost(Table, Text) line: 453	
	SearchField$3$1.run() line: 213	
        ...


Also, when using 4.5 M6, the Copy Build ID isn't working sometimes (no exception though).

So, please provide steps starting off a new workspace that allow to reproduce the problem using http://download.eclipse.org/eclipse/downloads/drops4/I20150429-2000/

Thanks.
Comment 10 Dani Megert CLA 2015-05-19 08:45:20 EDT
If someone can reproduce this we might consider it for RC2 or RC3, but for now moving to 4.6.
Comment 11 Lars Vogel CLA 2016-04-20 12:11:08 EDT
Mass move to 4.7 as M7 is approaching. Please move back in case you are planning to fix it for Neon.
Comment 12 Dani Megert CLA 2016-04-21 04:31:55 EDT
Lars, please reopen if you can still reproduce this using 4.6 M6.
Comment 13 Lars Vogel CLA 2016-04-21 06:17:34 EDT
(In reply to Dani Megert from comment #12)
> Lars, please reopen if you can still reproduce this using 4.6 M6.

Happens sometimes, unfortunately not reliable reproducable. Will reopen if I find the cause.