This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 433778 - quick access dialog not executing in the correct context
Summary: quick access dialog not executing in the correct context
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: PC All
: P3 major (vote)
Target Milestone: 4.4 RC1   Edit
Assignee: Lars Vogel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 362420 431707 431868
Blocks:
  Show dependency tree
 
Reported: 2014-04-29 11:27 EDT by Paul Webster CLA
Modified: 2014-05-16 08:05 EDT (History)
4 users (show)

See Also:
pwebster: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Webster CLA 2014-04-29 11:27:54 EDT
Hide the quick access Search Field, and then use CTRL+3 to open the dialog.

Type in cbi and when it selects Copy Build Id hit enter.

eclipse.buildId=4.4.0.I20140428-2000
java.version=1.7.0_51
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -os linux -ws gtk -arch x86_64 -data /opt/pwebster/workspaces/test44x

org.eclipse.ui
Error
Tue Apr 29 11:24:15 EDT 2014
org.eclipse.swt.SWTException: Widget is disposed

org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.swt.SWT.error(SWT.java:4441)
	at org.eclipse.swt.SWT.error(SWT.java:4356)
	at org.eclipse.swt.SWT.error(SWT.java:4327)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:476)
	at org.eclipse.swt.widgets.Widget.getDisplay(Widget.java:562)
	at org.eclipse.ui.internal.ide.commands.CopyBuildIdToClipboardHandler.execute(CopyBuildIdToClipboardHandler.java:44)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
	at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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:149)
	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:70)
	at org.eclipse.ui.internal.quickaccess.QuickAccessDialog$1$1.handleElementSelected(QuickAccessDialog.java:204)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.handleSelection(QuickAccessContents.java:461)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.access$0(QuickAccessContents.java:451)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents$1.keyPressed(QuickAccessContents.java:496)
	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:4462)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1412)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1397)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1424)
	at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:824)
	at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:3269)
	at org.eclipse.swt.widgets.Text.gtk_key_press_event(Text.java:1795)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2098)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:5506)
	at org.eclipse.swt.widgets.Text.windowProc(Text.java:2744)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4676)
	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:9074)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1253)
	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:2473)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3414)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1152)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1033)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:635)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:578)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
	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:379)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:233)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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 Paul Webster CLA 2014-04-30 10:28:26 EDT
René, Lars, this is important if we're advertising the QuickAccess changes for M7

PW
Comment 2 Lars Vogel CLA 2014-04-30 11:02:42 EDT
(In reply to Paul Webster from comment #1)
> René, Lars, this is important if we're advertising the QuickAccess changes
> for M7
> 
> PW

Looks like the handler does not find the Display, but this is hard to debug, as does not happen all the time, just sometimes to me. It looks like I only get this error if I have no open editors, but that might also be random.

As a fast fix for M7 we could use Display.getCurrent() and investigate after M7 in detail. Can you check if the following fixes the problem for you?

https://git.eclipse.org/r/#/c/25804/
Comment 3 Paul Webster CLA 2014-04-30 11:12:01 EDT
The problem is that org.eclipse.ui.handlers.HandlerUtil.getActiveShell(ExecutionEvent) is returning probably the quick access dialog shell as the active shell, but AFAIK quick access should have taken a snapshot IEvaluationContext with the workbench as its active shell.

We can't fix it in CopyBuildIdToClipboardHandler, that's just one command that could call getActiveShell(*).

PW
Comment 4 Lars Vogel CLA 2014-04-30 12:10:39 EDT
(In reply to Lars Vogel from comment #2)
> (In reply to Paul Webster from comment #1)

> https://git.eclipse.org/r/#/c/25804/

Patch updated.
Comment 5 Paul Webster CLA 2014-04-30 14:07:22 EDT
Patchset 4 (just rebased) still gives me an error:

org.eclipse.swt.SWTException: Widget is disposed
	at org.eclipse.swt.SWT.error(SWT.java:4441)
	at org.eclipse.swt.SWT.error(SWT.java:4356)
	at org.eclipse.swt.SWT.error(SWT.java:4327)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:476)
	at org.eclipse.swt.widgets.Widget.getDisplay(Widget.java:562)
	at org.eclipse.ui.internal.ide.commands.CopyBuildIdToClipboardHandler.execute(CopyBuildIdToClipboardHandler.java:44)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
	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:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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:149)
	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:54)
	at org.eclipse.ui.internal.quickaccess.QuickAccessDialog$1$1.handleElementSelected(QuickAccessDialog.java:215)
...
Comment 6 Paul Webster CLA 2014-04-30 14:14:36 EDT
I've uploaded a new change to https://git.eclipse.org/r/#/c/25804/

Could you confirm that still works for you?

PW
Comment 8 Paul Webster CLA 2014-05-01 13:16:30 EDT
In 4.4.0.I20140501-0200

PW
Comment 9 Paul Webster CLA 2014-05-02 09:15:04 EDT
The fix only fixes that specific problem.  Now Copy Qualified Name doesn't work.  If we want to display the quick access dialog, it should work as well as in 3.8.

eclipse.buildId=4.4.0.I20140501-0200
java.version=1.7.0_51
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -os linux -ws gtk -arch x86_64 -data /opt/pwebster/workspaces/build44x-2/

org.eclipse.ui
Error
Fri May 02 09:12:15 EDT 2014
There is no handler to execute for command org.eclipse.jdt.ui.edit.text.java.copy.qualified.name

org.eclipse.core.commands.NotHandledException: There is no handler to execute for command org.eclipse.jdt.ui.edit.text.java.copy.qualified.name
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:512)
	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.executeCommandInContext(LegacyHandlerService.java:396)
	at org.eclipse.ui.internal.quickaccess.CommandElement.execute(CommandElement.java:54)
	at org.eclipse.ui.internal.quickaccess.QuickAccessDialog$1$1.handleElementSelected(QuickAccessDialog.java:215)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.handleSelection(QuickAccessContents.java:461)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.access$0(QuickAccessContents.java:451)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents$1.keyPressed(QuickAccessContents.java:496)
	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:4462)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1412)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1397)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1424)
	at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:824)
	at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:3269)
	at org.eclipse.swt.widgets.Text.gtk_key_press_event(Text.java:1795)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:2098)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:5506)
	at org.eclipse.swt.widgets.Text.windowProc(Text.java:2744)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4676)
	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:9074)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1253)
	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:2473)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3414)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1152)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1033)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:635)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:578)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
	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:379)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:233)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	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 10 Missing name Mising name CLA 2014-05-05 13:00:38 EDT
Sorry, I didn't found the time so far.

A quick analyses of the problem shows that the org.eclipse.ui.internal.quickaccess.QuickAccessDialog$1$1.handleElementSelected() method was called after the dialog has been closed.

This closing causes the active leaf of the IEclipseContext to be set to null (see ShellActivationListener line 182: EclipseContext#dispose()). After this has been done the EclipseContext#getActive(String) method will not find an active leaf and so it uses the this reference to search for an active shell. The this reference in the particular case of the QuickAccessDialog is the IEclipseContext of the dialog which has already been closed and hence returns an disposed Shell.

So my suggestion to fix the problem is simply calling the QuickAccessElement#execute() method in a Display#asyncExec(). This brings all the context (regardless which one) into the correct state before the QuickAccessElement#execute() has been performed.

I've pushed the commit to gerrit: https://git.eclipse.org/r/25987
Comment 11 Lars Vogel CLA 2014-05-05 14:20:07 EDT
(In reply to René Brandstetter from comment #10)

> I've pushed the commit to gerrit: https://git.eclipse.org/r/25987

Paul, I tested the change and it works. Can you validate if that fits into your design?
Comment 12 Paul Webster CLA 2014-05-09 11:09:52 EDT
I don't think we can go that way, see comments on the review.

We need to look at the snapshot and executing in the snapshot.

PW
Comment 13 Lars Vogel CLA 2014-05-14 00:37:19 EDT
Rene, did you have a chance to look at the problem?
Comment 14 Paul Webster CLA 2014-05-14 11:14:52 EDT
I had a look at executionInContext(*), and I think it needs more work than we can safely do in RC1.

I'll re-examine the asyncExec as a workaround.

PW
Comment 16 Dani Megert CLA 2014-05-16 08:05:05 EDT
Verified in I20140515-1230.