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

Bug 327026

Summary: [Compatibility] NPE thrown when reopening an editor after moving a view into the shared area
Product: [Eclipse Project] e4 Reporter: Remy Suen <remy.suen>
Component: UIAssignee: Remy Suen <remy.suen>
Status: VERIFIED FIXED QA Contact: Remy Suen <remy.suen>
Severity: normal    
Priority: P3    
Version: 1.0   
Target Milestone: 4.1 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Remy Suen CLA 2010-10-05 13:07:19 EDT
1. Open an editor.
2. Move the 'Problems' view into the shared area.
3. Close the 'Problems' view.
4. Close the editor.
5. Reopen the same file from step 1.
6. An NPE is thrown.

java.lang.NullPointerException
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.getParentWithContext(PartServiceImpl.java:224)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.internalFixContext(PartServiceImpl.java:272)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:248)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:742)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:795)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2206)
	at org.eclipse.ui.internal.WorkbenchPage.access$14(WorkbenchPage.java:2173)
	at org.eclipse.ui.internal.WorkbenchPage$6.run(WorkbenchPage.java:2155)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2151)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2135)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2126)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)
	at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:354)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:164)
	at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:219)
Comment 1 Remy Suen CLA 2010-10-05 13:19:24 EDT
Since we have another part lying around in the stack, we actually don't unset the stack's selected element when the editor is closed in step 4 so this part actually ends up being leaked until the selected element changes.

This leaked part causes problems later down the road when we try to query it for its parent context. Will need to figure out if there are alternate code paths that will lead to this problem besides the one described above.
Comment 2 Remy Suen CLA 2010-10-05 14:01:13 EDT
(In reply to comment #1)
> Since we have another part lying around in the stack, we actually don't unset
> the stack's selected element when the editor is closed in step 4 so this part
> actually ends up being leaked until the selected element changes.

Fixed in CVS HEAD.

> This leaked part causes problems later down the road when we try to query it
> for its parent context. Will need to figure out if there are alternate code
> paths that will lead to this problem besides the one described above.

This seems to only happen if we have a stack with a selected element that's not actually a children of the stack. This is an invalid model state so having the code error out doesn't seem out of the ordinary to me. I will leave this code alone.
Comment 3 Remy Suen CLA 2010-10-26 10:00:21 EDT
Verified on Windows XP with I20101025-1602.