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

Bug 333680

Summary: NPE opening Compilers preference page
Product: [Eclipse Project] PDE Reporter: Michael Rennie <Michael_Rennie>
Component: UIAssignee: Ankur Sharma <ankur_sharma>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public
Version: 3.6   
Target Milestone: 3.7 M5   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Patch
none
WIP
none
Fix none

Description Michael Rennie CLA 2011-01-06 13:14:54 EST
code from HEAD (with the update from bug 333658)

Steps:
1. open the API Use Scans preference page
2. click the link to open the Errors/Warnings page
3. select a different tab on the errors/warnings page
4. try to navigate to the Compilers preference page

Expected

I open the Compilers preference page

Happens:

java.lang.NullPointerException
at org.eclipse.pde.internal.ui.preferences.CompilersPreferencePage.performCancel(CompilersPreferencePage.java:118)
at org.eclipse.jface.preference.PreferenceDialog$1.run(PreferenceDialog.java:260)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.preference.PreferenceDialog.cancelPressed(PreferenceDialog.java:258)
at org.eclipse.jface.preference.PreferenceDialog.handleShellCloseEvent(PreferenceDialog.java:895)
at org.eclipse.jface.window.Window$3.shellClosed(Window.java:687)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:98)
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.Shell.closeWidget(Shell.java:616)
at org.eclipse.swt.widgets.Shell.close(Shell.java:612)
at org.eclipse.swt.widgets.Shell.traverseEscape(Shell.java:2157)
at org.eclipse.swt.widgets.Control.traverse(Control.java:4665)
at org.eclipse.swt.widgets.Control.translateTraversal(Control.java:4638)
at org.eclipse.swt.widgets.Composite.translateTraversal(Composite.java:1541)
at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:2847)
at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:734)
at org.eclipse.swt.widgets.Tree.gtk_key_press_event(Tree.java:1977)
at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1743)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:4818)
at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:3505)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4359)
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:8256)
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:2258)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3158)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog.open(WorkbenchPreferenceDialog.java:215)
at org.eclipse.ui.internal.OpenPreferencesAction.run(OpenPreferencesAction.java:66)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
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.Display.runDeferredEvents(Display.java:3539)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3160)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
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:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Comment 1 Ankur Sharma CLA 2011-01-07 06:30:57 EST
Created attachment 186260 [details]
Patch
Comment 2 Ankur Sharma CLA 2011-01-07 06:31:30 EST
Fixed in HEAD.  See patch for changes.

Curtis, please verify.
Comment 3 Michael Rennie CLA 2011-01-07 10:16:10 EST
I am going to reopen this one. 

Verifying the fix I found that the reason we pass the 'data exists' check on the compilers preference page (leading to the NPE) is that the tab index set while traversing the link from the Use Scan page to the API Error / Warning page is left in the map. We should be removing this data entry once we are done with it.
Comment 4 Michael Rennie CLA 2011-01-07 10:25:53 EST
Curtis just reproduced an NPE traversing to the Project properties page because of the same poor 'data exists' check.

Steps

1. Open API error / warning pref page
2. press the link to configure project settings for a project
3. clear the filtering in the property dialog to show all pages
4. try to select the Compilers pref page
Comment 5 Curtis Windatt CLA 2011-01-07 12:41:16 EST
Created attachment 186293 [details]
WIP

Fixes the UI a bit (switching to the preference link block removed several settings) and removes the caching of the data map.  Still causes NPEs.
Comment 6 Curtis Windatt CLA 2011-01-10 16:56:25 EST
Created attachment 186440 [details]
Fix
Comment 7 Curtis Windatt CLA 2011-01-10 17:06:29 EST
Fixed in HEAD.  There is no guarantee what order createContents and applyData will be called in so we must cache the data until the contents are created and apply the effects then.
Comment 8 Ankur Sharma CLA 2011-01-25 04:34:47 EST
Verified in I20110124-1800