nil gcId before desroying GC
authorStefan Vogel <sv@exept.de>
Mon, 27 Sep 2004 16:08:22 +0200
changeset 4291 85475200669d
parent 4290 21ed28a08d5d
child 4292 153fc6f79fff
nil gcId before desroying GC
DeviceGraphicsContext.st
DisplaySurface.st
--- a/DeviceGraphicsContext.st	Mon Sep 27 10:49:08 2004 +0200
+++ b/DeviceGraphicsContext.st	Mon Sep 27 16:08:22 2004 +0200
@@ -3536,78 +3536,6 @@
     ^ Lobby
 !
 
-initialize
-    "setup everything for later use; actual work is done in
-     initColors and initFont, which are usually redefined."
-
-    super initialize.
-
-    "/ just in case, someone redefined new without setting device
-    device isNil ifTrue:[device := Screen current].
-
-    foreground isNil ifTrue:[foreground := Black].
-    background isNil ifTrue:[background := White].
-
-    "Modified: 10.1.1997 / 17:46:51 / cg"
-!
-
-prepareForReinit
-    "kludge - clear drawableId and gcId 
-     needed after snapin"
-
-    gcId := nil.
-    drawableId := nil.
-    deviceFont := nil
-!
-
-recreate
-    "sent after a snapin or a migration, reinit draw stuff for new device"
-
-    gcId := nil.
-    foreground notNil ifTrue:[
-        foreground := foreground onDevice:device
-    ].
-    background notNil ifTrue:[
-        background := background onDevice:device
-    ].
-    paint notNil ifTrue:[
-        paint := paint onDevice:device
-    ].
-    bgPaint notNil ifTrue:[
-        bgPaint := bgPaint onDevice:device
-    ].
-    font notNil ifTrue:[
-        font := font onDevice:device
-    ]
-
-    "Modified: 28.10.1996 / 13:25:02 / cg"
-!
-
-reinitialize
-    'DeviceGraphicsContext [warning]: reinit of ' errorPrint. self classNameWithArticle errorPrint.
-    ' failed' errorPrintCR
-
-    "Modified: 10.1.1997 / 17:47:06 / cg"
-!
-
-releaseGC
-    "destroy the associated device GC resource - can be done to be nice to the 
-     display if you know that you are done with a drawable."
-
-    foreground := background := paint := bgPaint := nil.
-
-    gcId notNil ifTrue:[
-        device destroyGC:gcId.
-        gcId := nil.
-        Lobby registerChange:self.
-    ].
-
-    "Created: 11.6.1996 / 22:07:30 / cg"
-    "Modified: 2.4.1997 / 19:36:30 / cg"
-! !
-
-!DeviceGraphicsContext methodsFor:'initialize / release'!
-
 initGC
     "since we do not need a gc-object for the drawable until something is
      really drawn, none is created.
@@ -3709,6 +3637,79 @@
         
 
     "Modified: / 29.1.1998 / 12:55:24 / cg"
+!
+
+initialize
+    "setup everything for later use; actual work is done in
+     initColors and initFont, which are usually redefined."
+
+    super initialize.
+
+    "/ just in case, someone redefined new without setting device
+    device isNil ifTrue:[device := Screen current].
+
+    foreground isNil ifTrue:[foreground := Black].
+    background isNil ifTrue:[background := White].
+
+    "Modified: 10.1.1997 / 17:46:51 / cg"
+!
+
+prepareForReinit
+    "kludge - clear drawableId and gcId 
+     needed after snapin"
+
+    gcId := nil.
+    drawableId := nil.
+    deviceFont := nil
+!
+
+recreate
+    "sent after a snapin or a migration, reinit draw stuff for new device"
+
+    gcId := nil.
+    foreground notNil ifTrue:[
+        foreground := foreground onDevice:device
+    ].
+    background notNil ifTrue:[
+        background := background onDevice:device
+    ].
+    paint notNil ifTrue:[
+        paint := paint onDevice:device
+    ].
+    bgPaint notNil ifTrue:[
+        bgPaint := bgPaint onDevice:device
+    ].
+    font notNil ifTrue:[
+        font := font onDevice:device
+    ]
+
+    "Modified: 28.10.1996 / 13:25:02 / cg"
+!
+
+reinitialize
+    'DeviceGraphicsContext [warning]: reinit of ' errorPrint. self classNameWithArticle errorPrint.
+    ' failed' errorPrintCR
+
+    "Modified: 10.1.1997 / 17:47:06 / cg"
+!
+
+releaseGC
+    "destroy the associated device GC resource - can be done to be nice to the 
+     display if you know that you are done with a drawable."
+
+    |id|
+
+    foreground := background := paint := bgPaint := nil.
+
+    id := gcId.
+    id notNil ifTrue:[
+        gcId := nil.
+        device destroyGC:id.
+        Lobby registerChange:self.
+    ].
+
+    "Created: 11.6.1996 / 22:07:30 / cg"
+    "Modified: 2.4.1997 / 19:36:30 / cg"
 ! !
 
 !DeviceGraphicsContext methodsFor:'private'!
@@ -3859,7 +3860,7 @@
 !DeviceGraphicsContext class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.102 2004-07-14 21:42:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.103 2004-09-27 14:08:22 stefan Exp $'
 ! !
 
 DeviceGraphicsContext initialize!
--- a/DisplaySurface.st	Mon Sep 27 10:49:08 2004 +0200
+++ b/DisplaySurface.st	Mon Sep 27 16:08:22 2004 +0200
@@ -2081,15 +2081,18 @@
     "view is about to be destroyed -
      first destroy menu if there is one and also destroy the GC.
      then the view is physically destroyed."
+
+    |id|
      
     middleButtonMenu notNil ifTrue:[
-	middleButtonMenu destroy.
-	middleButtonMenu := nil
+        middleButtonMenu destroy.
+        middleButtonMenu := nil
     ].
     keyCommands := nil.
-    gcId notNil ifTrue:[
-	device destroyGC:gcId.
-	gcId := nil
+    id := gcId.
+    id notNil ifTrue:[
+        gcId := nil.
+        device destroyGC:id.
     ].
     self destroyView.
     Lobby unregister:self.
@@ -2098,11 +2101,14 @@
 !
 
 destroyGC
-    "physically destroy the gc."
+    "physically destroy the gc"
+
+    |id|
      
-    gcId notNil ifTrue:[
-        device destroyGC:gcId.
-        gcId := nil
+    id := gcId.
+    id notNil ifTrue:[
+        gcId := nil.
+        device destroyGC:id.
     ].
 !
 
@@ -2446,7 +2452,7 @@
 !DisplaySurface class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/DisplaySurface.st,v 1.122 2004-09-21 20:14:29 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/DisplaySurface.st,v 1.123 2004-09-27 14:07:41 stefan Exp $'
 ! !
 
 DisplaySurface initialize!