Bug 153692 - Some Editor tabs remain open after closing a project
Summary: Some Editor tabs remain open after closing a project
Status: CLOSED DUPLICATE of bug 41431
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL: http://my.opera.com/behrangsa/blog/sh...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-13 04:49 EDT by Behrang Saeedzadeh CLA
Modified: 2009-12-16 11:08 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Behrang Saeedzadeh CLA 2006-08-13 04:49:53 EDT
Hi,

I am using Eclipse 3.2 WTP and there are times when I close my project, a few of the editors remain open (with no content though.)

I could reproduce this by following these steps:

I created a Dynamic Web Project, added a build.xml file. Opened the web.xml and the build.xml plus one index.html file. I closed the IDE. I restarted the IDE. I closed the project, and some of the editor tabs still remained opened (with empty content).

I am not sure if this is WTP 3.2 specific or an Eclipse 3.2 bug, though.

Regards,
Behi
Comment 1 David Williams CLA 2006-08-21 22:46:33 EDT
Amy, please see if you can reproduce, and if related to our code ... or that pesky ant editor :) 

Comment 2 Amy Wu CLA 2008-10-27 04:34:23 EDT
reassigning to inbox
Comment 3 Ian Tewksbury CLA 2009-12-16 10:12:29 EST
I can reproduce this.  The build.xml and index.html files stay open.  Will investigate.
Comment 4 Ian Tewksbury CLA 2009-12-16 10:59:30 EST
I have investigated this further and this is my findings.

STEPS:
1. Create a dynamic web project (though any project would probably do)
2. Create some documents, could be Java, xml, html, anything whos editor inhertis from the AbstractTextEditor (which is jsut about everything I would imagin)
3. Open all of these documents
4. Close eclipse
5. Open eclipse
6. Close the project containing all of these documents

RESULT:
Only the editor that was active is closed, all others stay open with no content with a messaging saying their file has gone missing

PROBLEM:
In org.eclipse.ui.texteditor.AbstractTextEditor the local class ElementStateListener is responsible for detecting if the backing file of the editor has been deleted (or in this case had its project closed) and then in turn closing the editor.  This listener gets registered in #updateDocumentProvider which is only called when #doSetInput is called on the editor.  This only happens when an editor gets focus.  Therefor if an editor never gets focus then its IElementStateListener will never be registered and when its backing project is closed the editor will not get the event that the file is now "deleted" and thus will not close.  Thus is the case here because all of the docuemnts that were open before Eclispe was shut down are restored when Eclipse is opened again, but only one of the editors gains focus and thus only that editor has its document provider set and is in turn the only editor to ahve its IElementStateListener registered and finally is because of all this the only editor to be closed when the project is closed.

If after step 5 you then click on each editor once to 'initialize' it (thus setting the editor input and in turn the document provider and IElementStateListener) then when you close the project all the editors close.
Comment 5 Ian Tewksbury CLA 2009-12-16 11:01:13 EST
See comment #4 for reason behind re-assigning to Platform.  I took a guess at the correct component based on the package name of AbstractTextEditor, if I got the component wrong please redirect.  Thank you.
Comment 6 Dani Megert CLA 2009-12-16 11:08:58 EST

*** This bug has been marked as a duplicate of bug 41431 ***