Tested with version 1.6.1 release on Windows.
If there are layers with unsaved edits in OpenJUMP and user ask computer to shut down, OpenJUMP is closed without any warnings and unsaved edits are lost. For comparison, Kosmo GIS 3.0 is keeping the computer in such a state that operating system sends a message that Kosmo prevents the shutdown and asks if user wants to cancel or do a forced shutdown.
Don't know how Windows is "killing" the Java VM during system shutdown. The only possibility to avoid lost of data is Runtime.addShutdownHook(). Here we can add a Thread, which ask's the user if there are unsaved layers. This Thread is startet if the Java VM is shutting down.
Implementing Runtime.addShutdownHook is not too complicated (some explanations here https://www.geeksforgeeks.org/jvm-shutdown-hook-java/). It is not an absolute guarantee as it depends how exactly the process is shutdown.
Question is : what can we do during this hook (must not be too long as the system may shut the process down anyway after a timeout).
I can see some options like
- save modifications (layers having a datasource but unsaved modification)
- save unsaved layers (layers without datasource)
- save project
Some could be checked by default.
Any thought ?
On 8/31/2020 14:26, ede wrote:
well. according to my tests that does a lot of nothing.in the best case
1.
run with 'java' so you have a console you can Ctrl+C in
gui is killed and java process hangs, probably in the "wanna save?" dialog.
2.
any other case
java killed, dead!
tested on Win10x64 with adoptopenjdk-1.8.0_265 64bit
..ede
applications i work with do not save anything without being explicitly told so. even on windows shutdown. the application simply don't exit and i'll have to force shutdown and go back save my work or at least deal with the dialog that popped up. usually the same as closing the application with unsaved changes.
tl;dr Runtime.addShutdownHook() should run com.vividsolutions.jump.workbench.ui.WorkbenchFrame.closeApplication() done.
implemented for testing in r6400
I could not see much effect either (same environment as yours).
Seems that the saving dialog appears a fraction of second, but the task killer is not one to be very patient.
Also I dicovered that tasks in the taskmanager can show their subprocesses : killing OpenJDK kill the whole process, but shuting OpenJUMP down open the save dialog (it already did it in the previous versions).
so it shall be done in OJ 2.x .. ede
On 31.08.2020 20:03, Giuseppe Aruta wrote:
Related
Bugs:
#501if JVM retrieves a shutdown signal there is little we can do. tried to add shutdown hooks and such, but JVM ends uncancellable. no way to show a save me dialog .
if we could find a way to catch the Ctrl+C ("kill") signal before it reaches the jvm? will tag it as oj_future for now