Bug 434317 - [spy] Spy doesn't work on context menus
Summary: [spy] Spy doesn't work on context menus
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 4.4 RC1   Edit
Assignee: Mickael Istria CLA
QA Contact:
URL: https://git.eclipse.org/r/26159
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2014-05-07 08:24 EDT by Mickael Istria CLA
Modified: 2014-05-13 17:53 EDT (History)
2 users (show)

See Also:
curtis.windatt.public: review+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2014-05-07 08:24:53 EDT
Using 4.4.M6, I use Alt-Shift-F2 to turn on Menu spy, and I access the context menu (for a given resource or on a text editor), in order to get the Spy infos for the selected menu.
First click: nothing happens
Second click: Spy is disabled so it trigger the action related to the menu.

Log shows a NPE:

!ENTRY org.eclipse.ui 4 0 2014-05-07 14:20:19.712
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
        at org.eclipse.pde.internal.runtime.spy.handlers.MenuSpyHandler.handleEvent(MenuSpyHandler.java:89)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1569)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1387)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3773)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3393)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1122)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1006)
        at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:147)
        at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:630)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:574)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:125)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:133)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:103)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:378)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:232)
        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:1462)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
Comment 1 Mickael Istria CLA 2014-05-07 08:50:17 EDT
It seems like event.display.getActiveShell() returns null.
Is it even normal that display.getActiveShell() can return null? Could it be an upstream (SWT) issue?
Comment 2 Mickael Istria CLA 2014-05-07 08:52:54 EDT
Also, this seems to be a regression compared to previous Luna milestones.
Comment 4 Mickael Istria CLA 2014-05-07 12:49:02 EDT
See proposal of a patch: https://git.eclipse.org/r/26159
Comment 5 Curtis Windatt CLA 2014-05-08 14:21:14 EDT
cc'ing Eric in case he has an idea why we can't get an active shell for the event.

I'm quite happy to accept patches for the plug-in spy feature for minor improvements.
Comment 6 Eric Moffatt CLA 2014-05-08 15:25:22 EDT
I see two possibilities that may be colluding to cause this.

a) Not sure but I think that menus are themselves Shells (which is why they can go outside the bounds of the app's shell.

b) Menus also spin there own version of the event loop (and grab focus)...
Comment 7 Mickael Istria CLA 2014-05-09 13:57:38 EDT
I didn't investigate a root cause for this issue. It used to work and it doesn't any more. I couldn't find any reason.
However, the suggested patch seems a working solution, for a problem we don't fully understand ;)
Comment 8 Curtis Windatt CLA 2014-05-12 11:58:01 EDT
Applied the fix to master:
http://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/?id=1502fac06e1619d0bbf856c0b8f451b3e76c2cc0

When I follow your steps the shell is always returned correctly.  However, forcing the shell to null and running your additional code finds and returns the correct shell.
Comment 9 Mickael Istria CLA 2014-05-12 12:01:30 EDT
(In reply to Curtis Windatt from comment #8)
> When I follow your steps the shell is always returned correctly.  However,
> forcing the shell to null and running your additional code finds and returns
> the correct shell.

So it can be a platform-specific behaviour?
I'm using Linux with GTK 3.8.