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

Bug 206364

Summary: [Preferences] Save preferences at timed intervals
Product: [Eclipse Project] Platform Reporter: Felix Berger <bflat1>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED DUPLICATE QA Contact: Oleg Besedin <ob1.eclipse>
Severity: enhancement    
Priority: P5 CC: digulla, Kevin_McGuire
Version: 3.4Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Log in 3.4M2 with jdt.ui.ClassFileEditorInputFactory throwing PartInitException none

Description Felix Berger CLA 2007-10-15 14:33:09 EDT
Eclipse does a pretty good job persisiting the state of two windows and their respective perspectives.

When I create a third window it is not persisted and the next time I start Eclipse only two windows are there.
Comment 1 Kevin McGuire CLA 2007-10-16 22:12:32 EDT
Interesting.  I was able to shut down with three windows and I got all three back, but I did get the following error from an editor from the first window:

Unable to create editor ID org.eclipse.jdt.ui.ClassFileEditor: Factory org.eclipse.jdt.ui.ClassFileEditorInputFactory returned null from createElement for editor id=org.eclipse.jdt.ui.ClassFileEditor name=FilteredResourcesSelectionDialog.class


Can you check to see if you have any related errors hidden in your log please?
Comment 2 Kevin McGuire CLA 2007-10-16 22:14:35 EDT
Created attachment 80513 [details]
Log in 3.4M2 with jdt.ui.ClassFileEditorInputFactory throwing PartInitException

Attaching my log in case related.
Comment 3 Felix Berger CLA 2007-10-17 16:03:19 EDT
It works with 3 windows when I exit Eclipse through the File menu.

Might be related to session management on KDE.
Comment 4 Kevin McGuire CLA 2007-10-17 18:33:56 EDT
(In reply to comment #3)
> It works with 3 windows when I exit Eclipse through the File menu.
> 
> Might be related to session management on KDE.

In the original bug description, how were you exiting?

On shutdown we write preference information which includes all your window state.  Its possible that an exception on shutdown, either in our code or another plugin's, could prevent this from completing.  Have you checked the log for anything related?  The .log file is in the .metadata directory of your workspace.

Finally, I should point out that my test was on XP and as you noted, you're on Linux, although its an unlikely factor.
Comment 5 Felix Berger CLA 2007-10-18 11:13:18 EDT
 (In reply to comment #4)

> > It works with 3 windows when I exit Eclipse through the File menu.
> >
> > Might be related to session management on KDE.
> 
> In the original bug description, how were you exiting?

Usually implicilty when shutting down KDE. But today the session management restored eclipse with all three windows though in different places.
 
> On shutdown we write preference information which includes all your window
> state.  Its possible that an exception on shutdown, either in our code or
> another plugin's, could prevent this from completing.  Have you checked the log
> for anything related?  The .log file is in the .metadata directory of your
> workspace.

Maybe the recent uprade to 3.3.1 fixed that and I didn't notice.

I could only find this warning at startup:

"The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes."

Comment 6 Kevin McGuire CLA 2007-10-18 11:42:22 EDT
(In reply to comment #5)
> Usually implicilty when shutting down KDE. But today the session management
> restored eclipse with all three windows though in different places.
...
> I could only find this warning at startup:
> 
> "The workspace exited with unsaved changes in the previous session; refreshing
> workspace to recover changes."

I don't run KDE/Unix so sorry for the stupid question but, do you mean you just log out of the OS or shut down the OS window manager, which kills all running programs (including Eclipse)?
Comment 7 Felix Berger CLA 2007-10-18 11:46:37 EDT
 (In reply to comment #6)

> I don't run KDE/Unix so sorry for the stupid question but, do you mean you just
> log out of the OS or shut down the OS window manager, which kills all running
> programs (including Eclipse)?

Yes, saving some session information for KDE to restore the program at startup on the same Desktop etc.

I'm not sure which signal is sent to the programs on logout though.
Comment 8 Kevin McGuire CLA 2007-10-18 11:56:44 EDT
Moving to core for comment.
Seems either,
1) this type of shutdown just doesn't work for eclipse
2) we're suppose to handle it but don't
Comment 9 DJ Houghton CLA 2007-10-22 10:46:46 EDT
Kevin is correct, we store preferences when we are told and we don't handle killing the process or any other means of exiting Eclipse that doesn't go through the regular plug-in life-cycle.

The message that you are getting in your log file means that workspace state has been lost. Not only your window state, but perhaps state of the resources as well. That is why we do a refresh to try and recover. For this reason, we do not recommend exiting Eclipse in this manner.
Comment 10 Felix Berger CLA 2007-10-22 11:06:18 EDT
It would be a very useful feature to handle signals correctly and persist data on a TERM signal. I found two Java articles regarding signal handling:

http://www.ibm.com/developerworks/ibm/library/i-signalhandling/
http://www.dclausen.net/javahacks/signal.html

A workaround would be to have the state be persisted every couple of minutes in a background thread if that's possible. Thus the user would at least get a very recent state of the workbench on relaunch.

Should I file a new bug with this feature request or reopen this one and rename it?
Comment 11 DJ Houghton CLA 2007-10-22 14:14:32 EDT
After consultation with members of the team (ok, Tom told me) it turns out we already have a request to be able to handle termination. See bug 46381. Let's use that one to address that problem.

I will re-open this report and we can use it to track down the UI feature request of saving preferences at timed intervals.
Comment 12 Susan McCourt CLA 2009-07-09 19:29:15 EDT
As per http://wiki.eclipse.org/Platform_UI/Bug_Triage_Change_2009
Comment 13 John Arthorne CLA 2011-05-25 08:51:32 EDT
*** Bug 337593 has been marked as a duplicate of this bug. ***
Comment 14 John Arthorne CLA 2011-05-25 08:55:59 EDT
From some digging around, the request to save UI state more frequently is essentially bug 2369 (whether this is done based on an interval or an explicit user action is a minor detail - if we had the mechanism in place we could easily allow both).

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