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

Bug 326312

Summary: [Preferences] NullPointerException when pressing ok in perspectives preferences, when all perspectives are closed
Product: [Eclipse Project] Platform Reporter: Jacek Pospychala <jacek.pospychala>
Component: UIAssignee: Oleg Besedin <ob1.eclipse>
Status: VERIFIED FIXED QA Contact: Oleg Besedin <ob1.eclipse>
Severity: normal    
Priority: P3 CC: ob1.eclipse, remy.suen, steven
Version: 3.6   
Target Milestone: 3.7 M3   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Adding a few null checks none

Description Jacek Pospychala CLA 2010-09-27 10:49:51 EDT
Found on 3.6.0

Steps to reproduce:
1. press Window -> Close All Perspectives
2. open prefrences, go to General > Perspectives, press OK

stack trace:
Daemon Thread [Thread-0] (Suspended (exception NullPointerException))	
	IDEPerspectivesPreferencePage(PerspectivesPreferencePage).performOk() line: 605	
	IDEPerspectivesPreferencePage.performOk() line: 114	
	PreferenceDialog$13.run() line: 964	
	SafeRunner.run(ISafeRunnable) line: 42	
	JFaceUtil$1.run(ISafeRunnable) line: 49	
	SafeRunnable.run(ISafeRunnable) line: 175	
	WorkbenchPreferenceDialog(PreferenceDialog).okPressed() line: 944	
	WorkbenchPreferenceDialog(FilteredPreferenceDialog).okPressed() line: 447	
	WorkbenchPreferenceDialog.okPressed() line: 169	
	WorkbenchPreferenceDialog(PreferenceDialog).buttonPressed(int) line: 233	
	Dialog$2.widgetSelected(SelectionEvent) line: 624	
	TypedListener.handleEvent(Event) line: 234	
	EventTable.sendEvent(Event) line: 84	
	Display.sendEvent(EventTable, Event) line: 3776	
	Button(Widget).sendEvent(Event) line: 1367	
	Button(Widget).sendEvent(int, Event, boolean) line: 1390	
	Button(Widget).sendEvent(int, Event) line: 1375	
	Button(Widget).notifyListeners(int, Event) line: 1187	
	Display.runDeferredEvents() line: 3622	
	Display.readAndDispatch() line: 3277	
	WorkbenchPreferenceDialog(Window).runEventLoop(Shell) line: 825	
	WorkbenchPreferenceDialog(Window).open() line: 801	
	WorkbenchPreferenceDialog.open() line: 211	
	OpenPreferencesAction.run() line: 65	
	CocoaUIEnhancer.runAction(String) line: 416	
	CocoaUIEnhancer.preferencesMenuItemSelected() line: 516	
	CocoaUIEnhancer.actionProc(long, long, long) line: 538	
	CocoaUIEnhancer.actionProc(int, int, int) line: 524	
	OS.objc_msgSendSuper(objc_super, int, int, int, int, boolean) line: not available [native method]	
	Display.applicationNextEventMatchingMask(int, int, int, int, int, int) line: 4483	
	Display.applicationProc(int, int, int, int, int, int) line: 4739	
	OS.objc_msgSend(int, int, int, int, int, boolean) line: not available [native method]	
	NSApplication.nextEventMatchingMask(int, NSDate, NSString, boolean) line: 85	
	Display.readAndDispatch() line: 3271	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2629	
	Workbench.runUI() line: 2593	
	Workbench.access$4(Workbench) line: 2427	
	Workbench$7.run() line: 670	
	Realm.runWithDefault(Realm, Runnable) line: 332	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 663	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 115	
	EclipseAppHandle.run(Object) line: 196	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 369	
	EclipseStarter.run(String[], Runnable) line: 179	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 597	
	Main.invokeFramework(String[], URL[]) line: 619	
	Main.basicRun(String[]) line: 574	
	Main.run(String[]) line: 1407	
	Main.main(String[]) line: 1383
Comment 1 Remy Suen CLA 2010-09-27 10:53:41 EDT
Similar to bug 293689 though the steps are different.
Comment 2 Jacek Pospychala CLA 2010-09-27 11:00:59 EDT
Indeed, I just tried steps from bug 293689 and stack trace looks pretty much the same as in this bug. E.g. NPE happening in PerspectivesPreferencePage.java:605 not in PerspectivesPreferencePage.java:604 as in bug 293689, probably due to different builds we use..

There's just some guard needed to protect from NULL in getActivePerspective() in:
FastViewManager fvm = page.getActivePerspective()
					.getFastViewManager();
Comment 3 Oleg Besedin CLA 2010-10-12 11:30:01 EDT
*** Bug 293689 has been marked as a duplicate of this bug. ***
Comment 4 Oleg Besedin CLA 2010-10-12 11:30:59 EDT
Another way to get NPE from the bug 293689:

> 1. Window > Save Perspective As...
> 2. Give it a name, say, 'Java 2', and click 'OK'.
> 3. Window > Preferences > General > Perspectives
> 4. Select 'Java2' in the table. Click 'Delete'.
> 5. A prompt comes up, click 'Yes'.
> 6. Click 'OK'.
> 7. You'll see a dialog try to materialize but never come up (a status handling
> bug?). An NPE is logged.
Comment 5 Oleg Besedin CLA 2010-10-12 11:31:30 EDT
Created attachment 180677 [details]
Adding a few null checks
Comment 6 Oleg Besedin CLA 2010-10-12 11:32:32 EDT
Patch applied to CVS Head. Thanks for reporting this!
Comment 7 Oleg Besedin CLA 2010-10-27 15:06:02 EDT
Verified in I20101026-2000.
Comment 8 Oleg Besedin CLA 2011-04-05 13:35:25 EDT
*** Bug 341939 has been marked as a duplicate of this bug. ***