AbstractLauncherApplication.st
changeset 17585 f5cf1f8f16f1
parent 17583 57658c266723
child 17608 bcb21d3a4f0d
--- a/AbstractLauncherApplication.st	Mon Jul 17 12:23:28 2017 +0200
+++ b/AbstractLauncherApplication.st	Mon Jul 17 12:23:43 2017 +0200
@@ -485,6 +485,52 @@
     ].
 
     "Modified: / 17-07-2017 / 10:14:09 / cg"
+!
+
+snapshotAndExit
+    "saves a snapshot image and exits, after asking for a fileName"
+
+    |fileName ok|
+
+    fileName := DialogBox
+                    request:(resources at:'filename for image:') withCRs
+              initialAnswer:(ObjectMemory nameForSnapshot) 
+                    okLabel:(resources at:'save & exit')
+                      title:(resources string:'save image & exit')
+                   onCancel:nil.
+
+    fileName notNil ifTrue:[
+        self showCursor:Cursor write.
+        [
+            ok := ObjectMemory snapShotOn:fileName.
+        ] ensure:[
+            self restoreCursors.
+        ].
+
+        ok ifFalse:[
+            "
+             snapshot failed for some reason (disk full, no permission etc.)
+             Do NOT exit in this case.
+            "
+            self warn:(resources string:'failed to save snapshot image (disk full or not writable)').
+        ] ifTrue:[
+            "
+             saveAllViews tells all views to shutdown neatly 
+             (i.e. offer a chance to save the contents to a file).
+
+             This is NOT required - all data should be in the snapshot ...
+             ... however, if remote disks/mountable filesystems are involved,
+             which may not be present the next time, it may make sense to 
+             uncomment it and query for saving - time will show which is better.
+            "
+"
+            self saveAllViews.
+"
+            Smalltalk exit
+        ]
+    ].
+
+    "Modified: / 17-07-2017 / 10:43:22 / cg"
 ! !
 
 !AbstractLauncherApplication methodsFor:'drag & drop'!