Project: Eclipse_Platform_UI
Bug 137341 [WorkbenchParts] WorkbenchPage.closeEditors calls IWorkbenchPart.getSaveables after disposing the part
Reported: 2006-04-18 15:28:22 | Status: resolved fixed

This violates the contract on IWorkbenchPart.dispose, which states that it will be the last method called on the part. One observable effect is that WorkbenchPage leaks Saveable reference counts for any editor that cleans up its saveable references on disposal and is not capable of handling getSaveables() after dispose(). This means that the "save as" dialog is often omitted. Also, the Saveables are only closed after the CHANGE_EDITOR_CLOSE event is fired from the window... this violates the contract on the CHANGE_EDITOR_CLOSE event, which is supposed to be fired after the part has been completely closed (for example, a CHANGE_EDITOR_CLOSE listener that tried to close an additional editor on the same saveable would not get the correct reference counts. POSSIBLE FIX: I believe the fix is as follows (in WorkbenchPage.closeEditors(IEditorReference[], boolean)) // Fire pre-removal changes for (int i = 0; i < editorRefs.length; i++) { IEditorReference ref = editorRefs[i]; // Notify interested listeners before the close window.firePerspectiveChanged(this, getPerspective(), ref, CHANGE_EDITOR_CLOSE); } deferUpdates(true); try { // ADD THIS BLOCK if(modelManager!=null) { modelManager.postClose(postCloseInfo); } // END OF ADDITION // Close all editors. for (int i = 0; i < editorRefs.length; i++) { IEditorReference ref = editorRefs[i]; // Remove editor from the presentation editorPresentation.closeEditor(ref); partRemoved((WorkbenchPartReference)ref); } } finally { deferUpdates(false); } // Notify interested listeners after the close window.firePerspectiveChanged(this, getPerspective(), CHANGE_EDITOR_CLOSE); // REMOVE THIS BLOCK: //if(modelManager!=null) { //modelManager.postClose(postCloseInfo); //} // END OF REMOVAL

Files changed in fix:
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java