This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 318211 - [Compatibility] QuickAccess will execute commands in an incorrect context
Summary: [Compatibility] QuickAccess will execute commands in an incorrect context
Status: VERIFIED FIXED
Alias: None
Product: e4
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 1.0   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: 1.0 RC3   Edit
Assignee: Remy Suen CLA
QA Contact: Remy Suen CLA
URL:
Whiteboard:
Keywords:
: 318744 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-06-28 12:38 EDT by Paul Webster CLA
Modified: 2010-07-27 12:31 EDT (History)
4 users (show)

See Also:
remy.suen: review+


Attachments
CommandProvider patch v1 (1.70 KB, patch)
2010-07-22 09:17 EDT, Remy Suen CLA
no flags Details | Diff
CommandProvider v02 (3.63 KB, patch)
2010-07-22 11:48 EDT, Paul Webster CLA
no flags Details | Diff
proposed patch (18.20 KB, patch)
2010-07-22 13:29 EDT, Boris Bokowski CLA
no flags Details | Diff
quick access v04 (18.11 KB, patch)
2010-07-22 14:59 EDT, Paul Webster CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Webster CLA 2010-06-28 12:38:00 EDT
I did a quickaccess CBI (copy build id) and it threw an NPE:


eclipse.buildId=I20100627-1659
java.fullversion=JRE 1.6.0 IBM J9 2.4 Linux x86-32 jvmxi3260sr8-20100401_55940 (JIT enabled, AOT enabled)
J9VM - 20100401_055940
JIT  - r9_20100401_15339
GC   - 20100308_AA
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=en_US
Command-line arguments:  -os linux -ws gtk -arch x86 -data /opt/pwebster/workspaces/e4


Error
Mon Jun 28 12:39:12 EDT 2010
java.lang.NullPointerException

java.lang.NullPointerException
	at org.eclipse.ui.internal.ide.commands.CopyBuildIdToClipboardHandler.execute(CopyBuildIdToClipboardHandler.java:44)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:56)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:600)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:42)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:192)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:169)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:101)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:135)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommandInContext(LegacyHandlerService.java:296)
	at org.eclipse.ui.internal.quickaccess.CommandElement.execute(CommandElement.java:49)
	at org.eclipse.ui.internal.quickaccess.SearchField$1.handleElementSelected(SearchField.java:47)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.handleSelection(QuickAccessContents.java:324)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents.access$0(QuickAccessContents.java:314)
	at org.eclipse.ui.internal.quickaccess.QuickAccessContents$1.keyPressed(QuickAccessContents.java:343)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:161)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1294)
	at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:730)
	at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:2839)
	at org.eclipse.swt.widgets.Text.gtk_key_press_event(Text.java:1451)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1743)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4794)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4372)
	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:8163)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1239)
	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:2224)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3169)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:658)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:579)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:102)
	at org.eclipse.ui.internal.Workbench$3.run(Workbench.java:537)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:521)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	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:369)
	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:48)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:600)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
Comment 1 Remy Suen CLA 2010-07-02 22:54:13 EDT
*** Bug 318744 has been marked as a duplicate of this bug. ***
Comment 2 Remy Suen CLA 2010-07-02 22:54:35 EDT
There may be a different NPE now, see bug 318744.
Comment 3 Paul Webster CLA 2010-07-05 10:38:01 EDT
This worked for me early in my usage of I20100701-1105


But not now:

null
Error
Mon Jul 05 10:40:11 EDT 2010
java.lang.NullPointerException

java.lang.NullPointerException
at org.eclipse.ui.internal.ide.commands.CopyBuildIdToClipboardHandler.execute(CopyBuildIdToClipboardHandler.java:44)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:56)
at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:42)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:193)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:170)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:101)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:135)
at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommandInContext(LegacyHandlerService.java:296)
at org.eclipse.ui.internal.quickaccess.CommandElement.execute(CommandElement.java:49)
at org.eclipse.ui.internal.quickaccess.SearchField$1.handleElementSelected(SearchField.java:60)
at org.eclipse.ui.internal.quickaccess.QuickAccessContents.handleSelection(QuickAccessContents.java:324)
at org.eclipse.ui.internal.quickaccess.QuickAccessContents.access$0(QuickAccessContents.java:314)
at org.eclipse.ui.internal.quickaccess.QuickAccessContents$1.keyPressed(QuickAccessContents.java:343)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:161)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1294)
at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:730)
at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:2839)
at org.eclipse.swt.widgets.Text.gtk_key_press_event(Text.java:1451)
at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1743)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4794)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4372)
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:8163)
at org.eclipse.swt.widgets.Display.eventProc(Display.java:1239)
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:2224)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3169)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:664)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:589)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:103)
at org.eclipse.ui.internal.Workbench$3.run(Workbench.java:535)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:519)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
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:369)
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:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
Comment 4 Remy Suen CLA 2010-07-17 16:55:30 EDT
Simplest fix is to just get the Display from the IWorkbench.

Or we can do it right and try to get ISources.ACTIVE_SHELL_NAME set properly in the context. Note that the shell may not necessarily be the shell of a workbench window.
Comment 5 Remy Suen CLA 2010-07-22 08:51:04 EDT
'Help > About' works but 'Ctrl+3 > About' doesn't. The former uses the window's context during command execution whereas the latter uses some (random?) anonymous context.
Comment 6 Remy Suen CLA 2010-07-22 09:17:44 EDT
Created attachment 174966 [details]
CommandProvider patch v1

Patch to change CommandProvider to delay the creation of the context snapshot until it's actually asked for.

This wasn't a problem in 3.x because the CommandProvider was only created when Ctrl+3 was actually hit. In 4.0, the CommandProvider is instantiated right in the beginning as it is constructed by an MToolControl so the snapshot quickly becomes "outdated".
Comment 7 Remy Suen CLA 2010-07-22 09:19:43 EDT
Paul, please review and perform a risk assessment.
Comment 8 Remy Suen CLA 2010-07-22 09:20:06 EDT
Boris, please evaluate the severity for RC3 consideration.
Comment 9 Paul Webster CLA 2010-07-22 11:48:44 EDT
Created attachment 174996 [details]
CommandProvider v02

Remy, what about this one.

PW
Comment 10 Remy Suen CLA 2010-07-22 11:57:42 EDT
(In reply to comment #9)
> Created an attachment (id=174996) [details]
> CommandProvider v02
> 
> Remy, what about this one.

Mm, looks good. This also allows us to capture the state of the application _before_ the dialog actually appears.
Comment 11 Boris Bokowski CLA 2010-07-22 11:59:26 EDT
I think we need to do even more changes, since the CommandProvider is going to cache all elements and won't recompute them ever again. I'll attach a new patch.
Comment 12 Remy Suen CLA 2010-07-22 12:10:27 EDT
(In reply to comment #11)
> I think we need to do even more changes, since the CommandProvider is going to
> cache all elements and won't recompute them ever again.

Indeed. It never picks up newly opened editors (and presumably amongst other problems). I guess no one ever uses Ctrl+3 to switch between editors.
Comment 13 Boris Bokowski CLA 2010-07-22 13:29:10 EDT
Created attachment 175003 [details]
proposed patch

Worked on this with Remy.
Comment 14 Paul Webster CLA 2010-07-22 14:59:46 EDT
Created attachment 175012 [details]
quick access v04

Contains a minor change to use the window context instead of the focus control context.

Remy, if you +1 this patch Boris says we can release it.

PW
Comment 15 Remy Suen CLA 2010-07-22 15:22:30 EDT
(In reply to comment #14)
> Remy, if you +1 this patch Boris says we can release it.

Released to CVS HEAD.
Comment 16 Remy Suen CLA 2010-07-27 12:31:38 EDT
Verified with I20100726-2152 on Windows XP.