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

Bug 319011

Summary: NPE when closing editor after closing a perspective
Product: [Eclipse Project] e4 Reporter: Oleg Besedin <ob1.eclipse>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: emoffatt, remy.suen
Version: 1.0   
Target Milestone: 1.0 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Stack trace
none
Reparent all contexts at or under a referenced (shared) element none

Description Oleg Besedin CLA 2010-07-06 10:16:57 EDT
Created attachment 173559 [details]
Stack trace

- Start up a clean Eclipse instance; create a project with 2 Java files; open them
- Open Debug perspective
- Close Debug perspective
- Close the Java file

NPE:

java.lang.NullPointerException
	at org.eclipse.ui.part.PageBookView$4.partHidden(PageBookView.java:1030)
	at org.eclipse.ui.internal.WorkbenchPage.firePartHidden(WorkbenchPage.java:2825)
	at org.eclipse.ui.internal.WorkbenchPage.access$9(WorkbenchPage.java:2818)


See the trace stack attached.

(Need two editors open to be able to reproduce.)
Comment 1 Remy Suen CLA 2010-07-06 11:12:42 EDT
The remaining editor (i.e. the one that wasn't closed) is being destroyed when the perspective is closed. This is a no-no.

Thread [main] (Suspended (breakpoint at line 312 in WorkbenchPage$1))	
	WorkbenchPage$1.remove(int) line: 312	
	WorkbenchPage$1.remove(int) line: 1	
	AbstractList$Itr.remove() line: 452	
	CompatibilityEditor.preDestroy() line: 94	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 79	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 618	
	MethodRequestor.execute() line: 47	
	InjectorImpl.processAnnotated(Class<Annotation>, Object, Class<?>, PrimaryObjectSupplier, PrimaryObjectSupplier, ArrayList<Class<?>>) line: 768	
	InjectorImpl.uninject(Object, PrimaryObjectSupplier) line: 154	
	InjectorImpl.disposed(PrimaryObjectSupplier) line: 317	
	MethodRequestor(Requestor).disposed(PrimaryObjectSupplier) line: 112	
	ContextObjectSupplier$ContextInjectionListener.update(IEclipseContext, int, Object[], IContextRecorder) line: 59	
	TrackableComputationExt.update(ContextChangeEvent) line: 90	
	TrackableComputationExt.doHandleInvalid(ContextChangeEvent, List<Scheduled>) line: 53	
	TrackableComputationExt(Computation).handleInvalid(ContextChangeEvent, List<Scheduled>) line: 59	
	EclipseContext.dispose() line: 196	
	EclipseContext.dispose() line: 186	
	PartRenderingEngine.clearContext(MContext) line: 561	
	PartRenderingEngine.removeGui(MUIElement) line: 513	
	PartRenderingEngine$1.handleEvent(Event) line: 124	
	UIEventHandler.handleEvent(Event) line: 41	
	EventHandlerWrapper.handleEvent(Event, Permission) line: 188	
	EventHandlerTracker.dispatchEvent(Object, Object, int, Object) line: 198	
	EventManager.dispatchEvent(Set, EventDispatcher, int, Object) line: 227	
	ListenerQueue.dispatchEventSynchronous(int, Object) line: 149	
	EventAdminImpl.dispatchEvent(Event, boolean) line: 139	
	EventAdminImpl.sendEvent(Event) line: 78	
	EventComponent.sendEvent(Event) line: 39	
	EventBroker.send(String, Object) line: 73	
	UIEventPublisher.notifyChanged(Notification) line: 58	
	PerspectiveImpl(BasicNotifierImpl).eNotify(Notification) line: 380	
	PerspectiveImpl(UIElementImpl).setToBeRendered(boolean) line: 267	
	ModelServiceImpl.removePerspectiveModel(MPerspective, MWindow) line: 591	
	WorkbenchPage.closePerspective(IPerspectiveDescriptor, boolean, boolean) line: 1077	
	PerspectiveSwitcher.closePerspective(MPerspective) line: 458	
	PerspectiveSwitcher.access$6(PerspectiveSwitcher, MPerspective) line: 455	
	PerspectiveSwitcher$14.widgetSelected(SelectionEvent) line: 450
Comment 2 Eric Moffatt CLA 2010-07-06 15:53:26 EDT
Created attachment 173593 [details]
Reparent all contexts at or under a referenced (shared) element
Comment 3 Eric Moffatt CLA 2010-07-06 15:54:08 EDT
Committed in >20100706. Applied the patch.
Comment 4 Eric Moffatt CLA 2010-07-06 16:00:31 EDT
Marking as FIXED.

There may still be a defect where the editor's contexts may not be being reparented during a perspective switch. If so I'll open a separate defect to handle that (less severe) case.