The bug and a discussion of it can be found in this
message and its thread.
Basically, when I log off or shut down my computer,
FreeMind doesn't prompt me to save outstanding changes.
It even deletes the temporary backup files that were
saved while I was editing.
To reproduce the problem without logging off your
computer, launch FreeMind from the command line using
the java command as follows.
Make some edits in the map, and wait for the automatic
save to occur. Then press Ctrl-C in the command prompt
window. You won't be prompted to save your changes, and
the temporary files will be deleted. I reproduced this
on Windows 2000 with java.runtime.version=1.5.0_02-b09.
To fix this, I used Runtime.addShutdownHook(Thread
hook) to detect a shutdown when the user is logging off
or shutting down. I added a shutDown() method to the
controller which checks whether the regular quit()
method has been called. If not, it triggers one final
automatic save with the
filesShouldBeDeletedAfterShutdown flag turned off.
I extracted the doAutomaticSave class out of the
MindMapModel class and into a new class called
BackupController. BackupController keeps a list of all
the doAutomaticSave tasks so that it can go through and
trigger them on an untidy shutdown. I thought
Controller was already pretty complicated, so that's
why I created a separate class for BackupController.
One thing I wasn't sure about was the effect of adding
the BackupController to the FreeMindApplet class. I'm
not sure how to test that.
The next logical step is to check for temp files on
start up and ask if the user wants to restore them.
When this patch gets accepted, I'll look into that.