On 10/13/2009 06:01 PM, Eli Green wrote:
I saved my image using Visual GST then tried to reload it from the command line 
like this:

gst-browser -I eli.im

The attached patch seems to do it, but I'd like confirmation from Gwen that (1) it is correct; (2) it does not leak memory.

Paolo
diff --git a/packages/visualgst/VisualGST.st b/packages/visualgst/VisualGST.st
index 0ce0636..2089da6 100644
--- a/packages/visualgst/VisualGST.st
+++ b/packages/visualgst/VisualGST.st
@@ -10,6 +10,14 @@ GtkMainWindow subclass: VisualGST [
         ^ uniqueInstance
     ]
 
+    VisualGST class >> uniqueInstance: anObject [
+        <category: 'private'>
+
+       (uniqueInstance notNil and: [ anObject notNil ])
+           ifTrue: [ self error: 'cannot override uniqueInstance' ].
+        uniqueInstance := anObject
+    ]
+
     VisualGST class >> createInstance [
         <category: 'private'>
 
@@ -201,7 +209,7 @@ THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.';
         http://bugzilla.kernel.org/show_bug.cgi?id=9138, so we have to
         check the permission of the directory rather than the file."
        File image parent isWriteable ifFalse: [ ^ self saveImageAs ].
-        saved := ObjectMemory snapshot not
+        self saveImage: [ObjectMemory snapshot]
     ]
 
     saveImageAs [
@@ -211,10 +219,16 @@ THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
SOFTWARE.';
            runNonBlockingAndDo: [ :dlg :res |
                res = GTK.Gtk gtkResponseAccept ifTrue: [ | name |
                    name := dlg getFilename.
-                   saved := (ObjectMemory snapshot: name) not ].
+                   self saveImage: [ObjectMemory snapshot: name] ].
                dlg destroy ]
     ]
 
+    saveImage: aBlock [
+       self class uniqueInstance: nil.
+       (saved := aBlock value not)
+           ifTrue: [self class uniqueInstance: self]
+    ]
+
     workspace [
        <category: 'tools events'>
        
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to