SimpleView.st
branchjv
changeset 7099 b19d8c33b045
parent 7083 db3f7c2127ef
parent 7094 349ae278b4f7
child 7111 96d1e688928a
--- a/SimpleView.st	Fri Jan 15 13:11:20 2016 +0000
+++ b/SimpleView.st	Sat Jan 16 10:16:43 2016 +0000
@@ -30,7 +30,7 @@
 		FlagRequestFocusOnPointerEnter
 		FlagDoNotRequestFocusOnPointerEnter FlagNativeWidget
 		FlagIsUnmappedModalBox FlagIsMDIChild FlagHiddenOnRealize
-		FlagHasExplicitExtent FlagTakeFocusWhenMapped'
+		FlagHasExplicitExtent FlagTakeFocusWhenMapped FlagBeingDestroyed'
 	poolDictionaries:''
 	category:'Views-Basic'
 !
@@ -771,31 +771,32 @@
 
 initialize
     DefaultStyle isNil ifTrue:[
-	Font initialize.
-	Form initialize.
-	Color initialize.
+        Font initialize.
+        Form initialize.
+        Color initialize.
     ].
     self == SimpleView ifTrue:[
-	Smalltalk addDependent:self   "/ to get language changes
+        Smalltalk addDependent:self   "/ to get language changes
     ].
 
     ReturnFocusWhenClosingModalBoxes := false.
 
-    FlagOriginChanged                   := 2r0000000000001.
-    FlagExtentChanged                   := 2r0000000000010.
-    FlagCornerChanged                   := 2r0000000000100.
-
-    FlagCanTab                          := 2r0000000001000.
-    FlagExtentChangedBeforeCreated      := 2r0000000010000.
-    FlagRequestFocusOnPointerEnter      := 2r0000000100000.
-    FlagDoNotRequestFocusOnPointerEnter := 2r0000001000000.
-    FlagNativeWidget                    := 2r0000010000000.
-    FlagIsUnmappedModalBox              := 2r0000100000000.
-    FlagIsMDIChild                      := 2r0001000000000.
-
-    FlagHiddenOnRealize                 := 2r0010000000000.
-    FlagHasExplicitExtent               := 2r0100000000000.
-    FlagTakeFocusWhenMapped             := 2r1000000000000.
+    FlagOriginChanged                   := 2r00000000000001.
+    FlagExtentChanged                   := 2r00000000000010.
+    FlagCornerChanged                   := 2r00000000000100.
+
+    FlagCanTab                          := 2r00000000001000.
+    FlagExtentChangedBeforeCreated      := 2r00000000010000.
+    FlagRequestFocusOnPointerEnter      := 2r00000000100000.
+    FlagDoNotRequestFocusOnPointerEnter := 2r00000001000000.
+    FlagNativeWidget                    := 2r00000010000000.
+    FlagIsUnmappedModalBox              := 2r00000100000000.
+    FlagIsMDIChild                      := 2r00001000000000.
+
+    FlagHiddenOnRealize                 := 2r00010000000000.
+    FlagHasExplicitExtent               := 2r00100000000000.
+    FlagTakeFocusWhenMapped             := 2r01000000000000.
+    FlagBeingDestroyed                  := 2r10000000000000.
 
     "Modified: / 09-12-2010 / 10:32:01 / cg"
 !
@@ -4460,13 +4461,32 @@
     "Modified: 17.6.1997 / 11:23:26 / cg"
 !
 
+isBeingDestroyed
+    "a flag which is set, when the view is being destroyed.
+     Can be checked to avoid some resizing and other layout reorganizations
+     (especially in panels), which otherwise occur while subviews are removed."
+
+    ^ flagBits bitTest:FlagBeingDestroyed.
+!
+
+isBeingDestroyed:aBoolean
+    "a flag which is set, when the view is being destroyed.
+     Can be checked to avoid some resizing and other layout reorganizations
+     (especially in panels), which otherwise occur while subviews are removed."
+
+    aBoolean ifTrue:[
+        flagBits := flagBits bitOr:FlagBeingDestroyed
+    ] ifFalse:[
+        flagBits := flagBits bitClear:FlagBeingDestroyed
+    ].
+!
+
 isHiddenOnRealize
     "return true, if the receiver will NOT be mapped when realized.
      False otherwise.
      The hiddenOnRealize flag is useful to create views which are
      to be made visible conditionally or later."
 
-    "/ ^ hiddenOnRealize
     ^ flagBits bitTest:FlagHiddenOnRealize.
 
     "Created: 17.6.1997 / 11:21:42 / cg"
@@ -7590,12 +7610,13 @@
     "unmap & destroy - make me invisible, destroy subviews then
      make me unknown to the device"
 
+    self isBeingDestroyed:true.
     realized ifTrue:[
-	self unmap.
+        self unmap.
     ].
     shown ifTrue:[
-	shown := false.
-	self changed:#visibility.
+        shown := false.
+        self changed:#visibility.
     ].
 
 "/    controller notNil ifTrue:[
@@ -7604,11 +7625,11 @@
 "/    ].
 
     subViews notNil ifTrue:[
-	self destroySubViews.
+        self destroySubViews.
     ].
     superView notNil ifTrue:[
-	superView removeSubView:self.
-	superView := nil
+        superView removeSubView:self.
+        superView := nil
     ].
     super destroy.
 
@@ -7619,13 +7640,13 @@
 "/    ].
 
     controller notNil ifTrue:[
-	controller release.
-	controller := nil.
+        controller release.
+        controller := nil.
     ].
 
     windowGroup notNil ifTrue:[
-	windowGroup removeView:self.
-	windowGroup := nil
+        windowGroup removeView:self.
+        windowGroup := nil
     ].
 
     self noticeOfWindowClose.
@@ -9805,6 +9826,7 @@
      realizing is done very late (after layout is fixed) to avoid
      visible rearranging of windows on the screen"
 
+    self isBeingDestroyed:false. "/ in case a view gets rerealized
     self realizeKeepingGroup:false at:nil iconified:false
 
     "Modified: 24.7.1997 / 13:14:28 / cg"
@@ -9871,6 +9893,7 @@
         ]
     ].
 
+    self isBeingDestroyed:false. "/ in case a view gets rerealized
     groupChange := false.
 
     (windowGroup notNil