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

Bug 66357

Summary: Eclipse stops opening editors
Product: [Eclipse Project] Platform Reporter: Kai-Uwe Maetzel <kai-uwe_maetzel>
Component: UIAssignee: Michael Van Meekeren <michaelvanmeekeren>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: P2 CC: douglas.pollock, eclipse, sxenos
Version: 3.0   
Target Milestone: 3.0 RC3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Kai-Uwe Maetzel CLA 2004-06-09 13:34:49 EDT
I200406082000

1) start with an empty workspace
2) create a simple project A
3) create a file f.txt in A
4) tranfer focus to the Navigator
5) modify f.txt externally
6) activate Eclipse without changing the active part
7) press close box of editor open for f.txt

-> A file changed dialog is posted by the editor. While the modal dialog is 
open, the editor gets closed. (see stack trace below)

8) press No in the dialog
9) double click on f.txt to open it again

-> nothing happens, no editor is opened (This is also the case when you have 
more files in the workspace and try to open an editor on some other file.)

Observation: 
I see that the editor is created and its init method is called. I also see 
that its createPartControl method is not called. I haven't seen any thrown 
exception in the process of opening the editor.


Stack trace of how the original editor on f.txt gets disposed. I'd suspect 
that the problem is related to the fact the part is closed while its 
activation event is being processed.

TextEditor(AbstractTextEditor).dispose() line: 2827
TextEditor(AbstractDecoratedTextEditor).dispose() line: 216
TextEditor.dispose() line: 108
EditorManager$Editor(WorkbenchPartReference).dispose() line: 391
EditorManager$Editor.dispose() line: 1420
WorkbenchPage$5.run() line: 1189
InternalPlatform.run(ISafeRunnable) line: 615
Platform.run(ISafeRunnable) line: 758
WorkbenchPage.disposePart(IWorkbenchPartReference) line: 1187
WorkbenchPage.closeEditor(IEditorPart, boolean) line: 988
WorkbenchPage.closeEditor(IEditorReference, boolean) line: 947
EditorPane.doHide() line: 95
EditorStack(PartStack).close(IPresentablePart) line: 339
EditorStack.close(IPresentablePart[]) line: 203
PartStack$1.close(IPresentablePart[]) line: 74
DefaultPartPresentation$1.closeButtonPressed(CTabItem) line: 107
PaneFolder.notifyCloseListeners(CTabItem) line: 484
PaneFolder$3.close(CTabFolderEvent) line: 169
CTabFolder.onMouse(Event) line: 2008
CTabFolder$1.handleEvent(Event) line: 293
EventTable.sendEvent(Event) line: 82
CTabFolder(Widget).sendEvent(Event) line: 796
Display.runDeferredEvents() line: 2719
Display.readAndDispatch() line: 2385
MessageDialog(Window).runEventLoop(Shell) line: 668
MessageDialog(Window).open() line: 648
MessageDialog.openQuestion(Shell, String, String) line: 342
TextEditor(AbstractTextEditor).handleEditorInputChanged() line: 3133
TextEditor(AbstractTextEditor).sanityCheckState(IEditorInput) line: 3263
TextEditor(StatusTextEditor).sanityCheckState(IEditorInput) line: 193
TextEditor(AbstractTextEditor).safelySanityCheckState(IEditorInput) line: 3241
AbstractTextEditor$ActivationListener.handleActivation() line: 767
AbstractTextEditor$ActivationListener.partActivated(IWorkbenchPart) line: 713
PartListenerList$1.run() line: 49
InternalPlatform.run(ISafeRunnable) line: 615
Platform.run(ISafeRunnable) line: 758
PartListenerList.firePartActivated(IWorkbenchPart) line: 47
WWinPartService$1.partActivated(IWorkbenchPartReference) line: 27
PartListenerList2$1.run() line: 45
InternalPlatform.run(ISafeRunnable) line: 615
Platform.run(ISafeRunnable) line: 758
PartListenerList2.firePartActivated(IWorkbenchPartReference) line: 43
WorkbenchPage.firePartActivated(IWorkbenchPart) line: 1358
WorkbenchPage.setActivePart(IWorkbenchPart) line: 2663
WorkbenchPage.requestActivation(IWorkbenchPart) line: 2358
EditorPane(PartPane).requestActivation() line: 304
EditorPane.requestActivation() line: 127
EditorPane(PartPane).setFocus() line: 325
EditorPane.setFocus() line: 154
PresentablePart.setFocus() line: 129
DefaultPartPresentation$2.mouseDown(MouseEvent) line: 132
TypedListener.handleEvent(Event) line: 132
EventTable.sendEvent(Event) line: 82
CTabFolder(Widget).sendEvent(Event) line: 796
Display.runDeferredEvents() line: 2719
Display.readAndDispatch() line: 2385
Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 1362
Workbench.runUI() line: 1333
Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 252
PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 141
IDEApplication.run(Object) line: 96
PlatformActivator$1.run(Object) line: 334
EclipseStarter.run(Object) line: 272
EclipseStarter.run(String[], Runnable) line: 128
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available 
[native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 84
NativeMethodAccessorImpl.invoke(Method, Object, Object[]) line: 57
DelegatingMethodAccessorImpl.invoke(Method, Object, Object[]) line: 59
Method.invoke(Object, Object[]) line: 390
Main.basicRun(String[]) line: 185
Main.run(String[]) line: 638
Main.main(String[]) line: 622
Comment 1 Kai-Uwe Maetzel CLA 2004-06-09 13:37:46 EDT
*** Bug 65046 has been marked as a duplicate of this bug. ***
Comment 2 Michael Van Meekeren CLA 2004-06-10 12:50:50 EDT
Adding the following isDisposed check in EditorPane.setFocus seems to stop 
this from happening.  Trying to find out why it was disposed.

public void setFocus() {
	super.setFocus();
	if (workbook.isDisposed()) {
		return;
	}
	workbook.becomeActiveWorkbook(true);
}
Comment 3 Nick Edgar CLA 2004-06-14 15:23:52 EDT
The problem is that while the partActivated notification is being processed
(triggered by DefaultPartPresentation$2.mouseDown), the editor is closed
(triggered by PaneFolder$3.close(CTabFolderEvent)).  The disposed editor
workbook is then made the active one, in EditorStack.becomeActiveWorkbook,
called from EditorPane.setFocus.

The call to becomeActiveWorkbook from EditorPane.setFocus() was added as part of
the fix for bug 62325.  I'm not sure why this was needed, but I don't feel
comfortable removing it without further investigation, or talking to Stephan first.

The patch in comment #2 checks whether the workbook has been disposed before
telling it to becomeActiveWorkbook, but I think that it would be better to
maintain the following invariants further down in EditorSashContainer:
- either activeEditorWorkbook is null, or it is a member of editorWorkbooks
- editorWorkbooks contains only non-disposed workbooks

The following patch to EditorSashContainer accomplishes this:

Index: EditorSashContainer.java
===================================================================
RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse
UI/org/eclipse/ui/internal/EditorSashContainer.java,v
retrieving revision 1.3
diff -u -r1.3 EditorSashContainer.java
--- EditorSashContainer.java	12 May 2004 18:22:46 -0000	1.3
+++ EditorSashContainer.java	14 Jun 2004 19:16:15 -0000
@@ -298,6 +298,12 @@
  * Set the editor workbook which is active.
  */
 public void setActiveWorkbook(EditorStack newWorkbook, boolean hasFocus) {
+    if (newWorkbook != null) {
+	    if (newWorkbook.isDisposed())
+	        return;
+	    if (!editorWorkbooks.contains(newWorkbook))
+	        return;
+    }
 	EditorStack oldWorkbook = activeEditorWorkbook;
 	activeEditorWorkbook = newWorkbook;
 	
Comment 4 Nick Edgar CLA 2004-06-14 16:04:21 EDT
Patch reviewed with Michael and released.
Comment 5 Nick Edgar CLA 2004-06-14 16:42:32 EDT
Marking as fixed.
Comment 6 Debbie Wilson CLA 2004-06-17 13:47:04 EDT
Verified I20040617 (0800).