Community
Participate
Working Groups
backport the fix to 4.2.2+ +++ This bug was initially created as a clone of Bug #404312 +++ The javadoc for HandledContributionItem.getContext() states that it should return "the closest context, or global context if none in the hierarchy", but when it its getContextForParent() method delegates to ModelServiceImpl.getContainingContext(), which delegates to ModelUtils.getContainingContext(), it simply returns null when it can't find one in the hierarchy. This causes an NPE in HandledContributionItem.canExecuteItem(), which assumes a non-null context. See stack trace below: Thread [main] (Suspended (breakpoint at line 194 in ModelUtils)) ModelUtils.getContainingContext(MApplicationElement) line: 194 ModelServiceImpl.getContainingContext(MUIElement) line: 276 HandledContributionItem.getContextForParent(MUIElement) line: 852 HandledContributionItem.getContext(MUIElement) line: 866 HandledContributionItem.canExecuteItem(Event) line: 822 HandledContributionItem.access$2(HandledContributionItem, Event) line: 817 HandledContributionItem$3.run() line: 216 SafeRunner.run(ISafeRunnable) line: 42 HandledContributionItem.updateItemEnablement() line: 243 HandledContributionItem$ToolItemUpdateTimer.run() line: 146 Display.runTimer(int) line: 4270 Display.messageProc(int, int, int, int) line: 3357 OS.DispatchMessageW(MSG) line: not available [native method] OS.DispatchMessage(MSG) line: 2546 Display.readAndDispatch() line: 3756 PartRenderingEngine$9.run() line: 1029 Realm.runWithDefault(Realm, Runnable) line: 332 PartRenderingEngine.run(MApplicationElement, IEclipseContext) line: 923 E4Workbench.createAndRunUI(MApplicationElement) line: 86 Workbench$5.run() line: 588 Realm.runWithDefault(Realm, Runnable) line: 332 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 543 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149 IDEApplication.start(IApplicationContext) line: 124 EclipseAppHandle.run(Object) line: 196 EclipseAppLauncher.runApplication(Object) line: 110 EclipseAppLauncher.start(Object) line: 79 EclipseStarter.run(Object) line: 353 EclipseStarter.run(String[], Runnable) line: 180 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: not available DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: not available Method.invoke(Object, Object...) line: not available Main.invokeFramework(String[], URL[]) line: 629 Main.basicRun(String[]) line: 584 Main.run(String[]) line: 1438 Main.main(String[]) line: 1414
Isn't this a duplicate of bug 411057? Or is the target milestone wrong?
*** This bug has been marked as a duplicate of bug 411057 ***