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

Bug 320790

Summary: NPE in ContributionsAnalyzer
Product: [Eclipse Project] e4 Reporter: Thomas Schindl <tom.schindl>
Component: UIAssignee: Remy Suen <remy.suen>
Status: VERIFIED FIXED QA Contact: Remy Suen <remy.suen>
Severity: blocker    
Priority: P3 CC: bokowski, john.arthorne, pwebster, remy.suen
Version: 1.0Flags: pwebster: review+
Target Milestone: 1.0 RC3   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Menu filter protection patch v1 none

Description Thomas Schindl CLA 2010-07-24 04:38:43 EDT
This is the I20100723-2001 build and I somehow managed to get into a state where all context menus result in this NPE!

java.lang.NullPointerException
at org.eclipse.e4.ui.internal.workbench.ContributionsAnalyzer.gatherMenuContributions(ContributionsAnalyzer.java:97)
at org.eclipse.e4.ui.workbench.swt.modeling.MenuServiceFilter.showMenu(MenuServiceFilter.java:134)
at org.eclipse.e4.ui.workbench.swt.modeling.MenuServiceFilter.handleMenu(MenuServiceFilter.java:117)
at org.eclipse.e4.ui.workbench.swt.modeling.MenuServiceFilter.handleEvent(MenuServiceFilter.java:103)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1031)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3775)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1367)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1390)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1371)
at org.eclipse.swt.widgets.Menu.menuWillOpen(Menu.java:689)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5030)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Display.applicationNextEventMatchingMask(Display.java:4483)
at org.eclipse.swt.widgets.Display.applicationProc(Display.java:4739)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSApplication.nextEventMatchingMask(NSApplication.java:85)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3271)
Comment 1 Thomas Schindl CLA 2010-07-24 04:49:21 EDT
It looks like removing the deltas.xml makes my system usable once more so probably it was a problem in not cleaning my deltas.
Comment 2 Thomas Schindl CLA 2010-07-24 06:26:30 EDT
Ok here's how to reproduce:
a) Install EMF-SDK
b) Open our UIElement.ecore

=> Peng you get NPEs everywhere until you close the editor!
Comment 3 Remy Suen CLA 2010-07-24 06:37:39 EDT
(In reply to comment #2)
> a) Install EMF-SDK
> b) Open our UIElement.ecore
> 
> => Peng you get NPEs everywhere until you close the editor!

Confirmed. Unlike Text that contributes to known menus like 'Edit' and 'Navigate', EMF seems to contribute to...I don't know what, but it's 'null' anyway.
Comment 4 Remy Suen CLA 2010-07-24 06:52:58 EDT
(In reply to comment #3)
> EMF seems to contribute to...I don't know what, but it's 'null'
> anyway.

Upon investigation, EMF is spawning a completely new menu in the main menu bar named 'Sample Ecore Editor'.

For referencing purposes, this regression was introduced by bug 318856.
Comment 5 Remy Suen CLA 2010-07-24 07:39:23 EDT
Created attachment 175132 [details]
Menu filter protection patch v1
Comment 6 Boris Bokowski CLA 2010-07-24 17:49:13 EDT
+1 from me. This does mean that the top level menu won't show up, right? Should be added to the known issues wiki page.
Comment 7 Remy Suen CLA 2010-07-24 18:01:08 EDT
Paul, please review and perform a risk assessment.

The gist of it here is that EMF spawns a completely new menu manager (for its 'Sample Ecore Editor') and then adds it to the top level menu manager from the window. Since that's all modeled, the window's menu manager is just some throw away MenuManager that's constructed without any parameters (such as an id) so when we try to place an MMC under it, its parent id is null.

The SafeRunner is self-explanatory here. Our code is going to die elsewhere from runtime exceptions but we definitely don't want to kill SWT while we're at it.
Comment 8 Paul Webster CLA 2010-07-24 19:58:08 EDT
I've released this.

PW
Comment 9 Remy Suen CLA 2010-07-27 13:01:18 EDT
Verified with I20100726-2152 on Windows XP.