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

Bug 350459

Summary: [Compatibility] NPE with GEF editor
Product: [Eclipse Project] Platform Reporter: Remy Suen <remy.suen>
Component: UIAssignee: Remy Suen <remy.suen>
Status: VERIFIED FIXED QA Contact: Remy Suen <remy.suen>
Severity: blocker    
Priority: P3 CC: yves.yang
Version: 4.1   
Target Milestone: 4.1.1   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 350390    
Bug Blocks:    
Attachments:
Description Flags
MenuHelper patch v1 none

Description Remy Suen CLA 2011-06-27 11:19:58 EDT
+++ This bug was initially created as a clone of Bug #350390 +++

I met a NPE exception with GEF using eclipse-SDK-4.1-Win32:

java.lang.NullPointerException
	at org.eclipse.ui.internal.commands.CommandImageManager.getImageDescriptor(CommandImageManager.java:274)
	at org.eclipse.ui.internal.commands.CommandImageManager.getImageDescriptor(CommandImageManager.java:237)
	at org.eclipse.ui.internal.commands.CommandImageService.getImageDescriptor(CommandImageService.java:125)
	at org.eclipse.ui.internal.menus.MenuHelper.getIconURI(MenuHelper.java:898)
	at org.eclipse.ui.internal.menus.MenuHelper.createToolItem(MenuHelper.java:723)
	at org.eclipse.ui.internal.CoolBarToTrimManager.fill(CoolBarToTrimManager.java:638)
	at org.eclipse.ui.internal.CoolBarToTrimManager.update(CoolBarToTrimManager.java:584)
	at org.eclipse.ui.internal.WorkbenchWindow.updateActionBars(WorkbenchWindow.java:1643)
	at org.eclipse.ui.internal.WWinActionBars.updateActionBars(WWinActionBars.java:113)
	at org.eclipse.ui.SubActionBars.updateActionBars(SubActionBars.java:611)
	at org.eclipse.ui.internal.e4.compatibility.ActionBars.updateActionBars(ActionBars.java:96)
	at org.eclipse.ui.part.PageBookView.showPageRec(PageBookView.java:1015)
	at org.eclipse.ui.part.PageBookView.createPartControl(PageBookView.java:490)
	at org.eclipse.ui.views.properties.PropertySheet.createPartControl(PropertySheet.java:157)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:122)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityView.createPartControl(CompatibilityView.java:93)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:256)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


It seems the error is in the class org.eclipse.ui.internal.menus.MenuHelper at the line 723, 

			MDirectToolItem toolItem = MenuFactoryImpl.eINSTANCE.createDirectToolItem();
			String itemId = item.getId();
			toolItem.setElementId(itemId == null ? id : itemId);
			String iconURI = getIconURI(action.getImageDescriptor());
			if (iconURI == null) {
				iconURI = getIconURI(id, application.getContext());

The call of the last line above id is null. It should be the value of "itemId".
Comment 1 Remy Suen CLA 2011-06-27 11:31:47 EDT
Created attachment 198659 [details]
MenuHelper patch v1
Comment 2 Remy Suen CLA 2011-06-27 11:34:28 EDT
(In reply to comment #1)
> Created attachment 198659 [details]
> MenuHelper patch v1

Patch released to R4_1_maintenance.
Comment 3 Remy Suen CLA 2011-08-26 14:29:58 EDT
I opened two example GEF editors and they look good to me.

Verified with M20110817-2001 on Windows XP. Thanks again for reporting this bug, Yves!