Project: Eclipse_Platform_UI
Bug 75835 [EditorMgmt] [Contributions] Action Bars are not cleaned up after an Editor throws PartInitException
Reported: 2004-10-07 14:51:55 | Status: verified fixed

If an Editor part throws a PartInitException during initialization (in the org.eclipse.ui.IEditorPart#init(IEditorSite, IEditorInput) method), the Action Bars are not cleaned up properly. This can cause problems. In my case I had following behavior: 1) An editor of type 1 would throw the PartInitException (and it has some toolbar actions defined) 2) Eclipse would deal with that and not display the editor (or the toolbar) 3) Another editor type (type 2) with a toolbar is invoked and everything opens properly 4) Close editor of type 2 - the toolbar of the editor type 1 is displayed and cannot be removed until the application is restarted. I have tracked this down to the org.eclipse.ui.internal.EditorManager#createSite(...). Before calling part.init (), it creates action bars but if init() throws an exception they are not disposed of. I checked the closeEditor method in the same class - it invokes the disposeEditorActionBars() method which is supposed to clean up the action bars. There are really no valid work-arounds (except not throwing the PartInititException which is part of the API) - all of these classes and methods are internal and even access private fields that are not exposed through getters. It seems that createSite() should catch the exception, call the disposeEditorActionBars() method and then re-throw.

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