#valueNowOrOnUnwindDo: -> #ensure:
authorClaus Gittinger <cg@exept.de>
Tue, 26 Feb 2002 13:58:22 +0100
changeset 3604 e32b5044a59e
parent 3603 3665199a413f
child 3605 b5c70808fc8c
#valueNowOrOnUnwindDo: -> #ensure:
SimpleView.st
WindowGroup.st
WindowSensor.st
--- a/SimpleView.st	Tue Feb 26 13:18:52 2002 +0100
+++ b/SimpleView.st	Tue Feb 26 13:58:22 2002 +0100
@@ -3351,7 +3351,7 @@
         builder window:self.
         [
             anApplication buildSubCanvas:subSpec withBuilder:builder.
-        ] valueNowOrOnUnwindDo:[
+        ] ensure:[
             savedView notNil ifTrue:[
                 builder window:savedView.
             ].
@@ -3376,7 +3376,7 @@
 "/        builder window:self.
 "/        [
 "/            anApplication buildSubCanvas:subSpec withBuilder:builder.
-"/        ] valueNowOrOnUnwindDo:[
+"/        ] ensure:[
 "/            savedView notNil ifTrue:[
 "/                builder window:savedView.
 "/            ]
@@ -4059,50 +4059,50 @@
 
     ok := true.
     bitmaps := #('wheel1' 'wheel2' 'wheel3' 'wheel4') 
-	       collect:[:name |
-		   |f|
-
-		   f := Smalltalk imageFromFileNamed:(name , '.xbm') forClass:self class.
-		   f isNil ifTrue:[
-			('SimpleView [warning]: no bitmap file: ' , name , '.xbm') errorPrintCR.
-			ok := false
-		   ].
-		   f
-	       ].
+               collect:[:name |
+                   |f|
+
+                   f := Smalltalk imageFromFileNamed:(name , '.xbm') forClass:self class.
+                   f isNil ifTrue:[
+                        ('SimpleView [warning]: no bitmap file: ' , name , '.xbm') errorPrintCR.
+                        ok := false
+                   ].
+                   f
+               ].
 
     mask := Smalltalk imageFromFileNamed:'wheelm.xbm' forClass:self class.
     mask isNil ifTrue:[
-	('SimpleView [warning]: no bitmap file: wheelm.xbm') errorPrintCR.
-	ok := false
+        ('SimpleView [warning]: no bitmap file: wheelm.xbm') errorPrintCR.
+        ok := false
     ].
 
     ok ifFalse:[
-	self cursor:Cursor wait.
-	aBlock valueNowOrOnUnwindDo:[
-	    self cursor:oldCursor
-	]
+        self cursor:Cursor wait.
+        aBlock ensure:[
+            self cursor:oldCursor
+        ]
     ] ifTrue:[
-	cursors := bitmaps collect:[:form | (Cursor sourceForm:form
-						      maskForm:mask
-							  hotX:8
-							  hotY:8) onDevice:device].
-
-	process := [
-		    Delay waitForSeconds:0.25.
-		    [true] whileTrue:[
-			cursors do:[:curs |
-			    self cursor:curs.
-			    Delay waitForSeconds:0.05
-			]
-		    ]
-		   ] fork.
-
-	Processor activeProcess priority:7.
-	aBlock valueNowOrOnUnwindDo:[
-	    Processor activeProcess priority:8.
-	    process terminate.
-	    self cursor:oldCursor
-	]
+        cursors := bitmaps collect:[:form | (Cursor sourceForm:form
+                                                      maskForm:mask
+                                                          hotX:8
+                                                          hotY:8) onDevice:device].
+
+        process := [
+                    Delay waitForSeconds:0.25.
+                    [true] whileTrue:[
+                        cursors do:[:curs |
+                            self cursor:curs.
+                            Delay waitForSeconds:0.05
+                        ]
+                    ]
+                   ] fork.
+
+        Processor activeProcess priority:7.
+        aBlock ensure:[
+            Processor activeProcess priority:8.
+            process terminate.
+            self cursor:oldCursor
+        ]
     ].
 
     "
@@ -4121,35 +4121,35 @@
 
     wasBlocked := OperatingSystem blockInterrupts.
     [
-	|deps|
-
-	deps := dependents.
-	"/
-	"/ store the very first dependent directly in
-	"/ the dependents instVar
-	"/
-	(deps isNil and:[anObject isCollection not]) ifTrue:[
-	    dependents := anObject
-	] ifFalse:[
-	    "/
-	    "/ store more dependents in the dependents collection
-	    "/
-	    deps isCollection ifTrue:[
-		deps add:anObject
-	    ] ifFalse:[
-		deps == anObject ifFalse:[
-		    deps isNil ifTrue:[
-			dependents := (IdentitySet with:anObject)
-		    ] ifFalse:[
-			dependents := (IdentitySet with:deps with:anObject)
-		    ]
-		]
-	    ]
-	]
-    ] valueNowOrOnUnwindDo:[
-	wasBlocked ifFalse:[
-	    OperatingSystem unblockInterrupts
-	]
+        |deps|
+
+        deps := dependents.
+        "/
+        "/ store the very first dependent directly in
+        "/ the dependents instVar
+        "/
+        (deps isNil and:[anObject isCollection not]) ifTrue:[
+            dependents := anObject
+        ] ifFalse:[
+            "/
+            "/ store more dependents in the dependents collection
+            "/
+            deps isCollection ifTrue:[
+                deps add:anObject
+            ] ifFalse:[
+                deps == anObject ifFalse:[
+                    deps isNil ifTrue:[
+                        dependents := (IdentitySet with:anObject)
+                    ] ifFalse:[
+                        dependents := (IdentitySet with:deps with:anObject)
+                    ]
+                ]
+            ]
+        ]
+    ] ensure:[
+        wasBlocked ifFalse:[
+            OperatingSystem unblockInterrupts
+        ]
     ]
 
     "Modified: 8.1.1997 / 23:40:30 / cg"
@@ -4225,31 +4225,31 @@
 
     wasBlocked := OperatingSystem blockInterrupts.
     [
-	|deps sz dep|
-
-	deps := dependents.
-	deps notNil ifTrue:[
-	    deps isCollection ifTrue:[
-		deps remove:anObject ifAbsent:[].
-		(sz := deps size) == 0 ifTrue:[
-		    dependents := nil
-		] ifFalse:[
-		    sz == 1 ifTrue:[
-			(dep := deps first) isCollection ifFalse:[
-			    dependents := dep
-			]
-		    ]
-		]
-	    ] ifFalse:[
-		deps == anObject ifTrue:[
-		    dependents := nil
-		]
-	    ]
-	]
-    ] valueNowOrOnUnwindDo:[
-	wasBlocked ifFalse:[
-	    OperatingSystem unblockInterrupts
-	]
+        |deps sz dep|
+
+        deps := dependents.
+        deps notNil ifTrue:[
+            deps isCollection ifTrue:[
+                deps remove:anObject ifAbsent:[].
+                (sz := deps size) == 0 ifTrue:[
+                    dependents := nil
+                ] ifFalse:[
+                    sz == 1 ifTrue:[
+                        (dep := deps first) isCollection ifFalse:[
+                            dependents := dep
+                        ]
+                    ]
+                ]
+            ] ifFalse:[
+                deps == anObject ifTrue:[
+                    dependents := nil
+                ]
+            ]
+        ]
+    ] ensure:[
+        wasBlocked ifFalse:[
+            OperatingSystem unblockInterrupts
+        ]
     ]
 
     "Modified: 8.1.1997 / 23:41:39 / cg"
@@ -8878,120 +8878,120 @@
     |tops mainView mainViewID previousGroup |
 
     self isPopUpView ifFalse:[
-	ModalBox usingTransientViews ifTrue:[
-	    "make view only transient, if there is a visible topView.
-	     If none of them is visible, we do want an icon for ourself"
+        ModalBox usingTransientViews ifTrue:[
+            "make view only transient, if there is a visible topView.
+             If none of them is visible, we do want an icon for ourself"
         
-	    mainGroup notNil ifTrue:[
-		(tops := mainGroup topViews) notNil ifTrue:[
-		    tops notEmpty ifTrue:[
-			mainView := tops detect:[:v| v shown] ifNone:nil.
-			mainView notNil ifTrue:[
-			    mainViewID := mainView id.
-			]
-		    ]
-		].
-	    ].
-
-	    mainViewID isNil ifTrue:[
-		self origin:(device center - (self extent//2))
-	    ].
-
-	    drawableId isNil ifTrue:[self create].
-	    mainView notNil ifTrue:[
-		device setTransient:drawableId for:mainViewID.
-	    ].
-	].
+            mainGroup notNil ifTrue:[
+                (tops := mainGroup topViews) notNil ifTrue:[
+                    tops notEmpty ifTrue:[
+                        mainView := tops detect:[:v| v shown] ifNone:nil.
+                        mainView notNil ifTrue:[
+                            mainViewID := mainView id.
+                        ]
+                    ]
+                ].
+            ].
+
+            mainViewID isNil ifTrue:[
+                self origin:(device center - (self extent//2))
+            ].
+
+            drawableId isNil ifTrue:[self create].
+            mainView notNil ifTrue:[
+                device setTransient:drawableId for:mainViewID.
+            ].
+        ].
     ].
 
     self raise.
 
     Processor activeProcessIsSystemProcess ifTrue:[
-	"
-	 put myself into the modal group, let it handle events for
-	 me as well. This is only a half way solution, since the view
-	 is not modal at all ... however, the only situation
-	 where this happens is with modal boxes popped while in a
-	 modal browser. You will forgive me for that inconvenience.
-	"
-	windowGroup := mainGroup.
-	mainGroup notNil ifTrue:[mainGroup addTopView:self].
-	self realize
+        "
+         put myself into the modal group, let it handle events for
+         me as well. This is only a half way solution, since the view
+         is not modal at all ... however, the only situation
+         where this happens is with modal boxes popped while in a
+         modal browser. You will forgive me for that inconvenience.
+        "
+        windowGroup := mainGroup.
+        mainGroup notNil ifTrue:[mainGroup addTopView:self].
+        self realize
     ] ifFalse:[
-	previousGroup := WindowGroup activeGroup.
-
-	"
-	 show a stop-cursor in the main group
-	"
-	mainGroup notNil ifTrue:[
-	    self isPopUpView ifFalse:[
-		mainGroup showCursor:(Cursor stop).
-		(previousGroup notNil and:[previousGroup ~~ mainGroup]) ifTrue:[
-		    previousGroup showCursor:(Cursor stop).
-		].
-	    ]
-	].
-
-	"
-	 create a new window group and put myself into it
-	"
-	windowGroup := WindowGroup new.
-	windowGroup addTopView:self.
-	windowGroup setPreviousGroup:previousGroup.
-
-	superView notNil ifTrue:[
-	    "/
-	    "/ special: this is a modal subview,
-	    "/ prevent the view from reassigning its windowGroup when realized
-	    "/ (subviews normally place themself into the superviews group)
-	    "/        
-	    windowGroup isForModalSubview:true.
-	].
-
-	"
-	 go dispatch events in this new group
-	 (thus current windowgroup is blocked from interaction)
-	"
-	AbortSignal handle:[:ex |
-	    self hide.
-	    ex return.
-	] do:[
-	    [
-		[
-		    windowGroup startupModal:[realized and:aBlock] forGroup:mainGroup
-		] valueOnUnwindDo:[
-		    self hide.
-		]
-	    ] valueNowOrOnUnwindDo:[
-		mainGroup notNil ifTrue:[
-		    mainGroup graphicsDevice sync.
-		    "/ ensure that eventListener runs here ...
-		    Delay waitForSeconds:0.05.    
-		    mainGroup processExposeEvents.
-
-		    ReturnFocusWhenClosingModalBoxes ifTrue:[
-			"
-			 return input focus to previously active groups top.
-			 This helps with windowmanagers which need an explicit click
-			 on the view for the focus.
-			"
-			tops := mainGroup topViews.
-			(tops notNil and:[tops notEmpty]) ifTrue:[
-			    tops first getKeyboardFocus
-			].
-		    ].
-
-		    "
-		     restore cursors in the main group & flush its buffered key & mouse events
-		    "
-		    mainGroup restoreCursors.
-		    (previousGroup notNil and:[previousGroup ~~ mainGroup]) ifTrue:[
-			previousGroup restoreCursors.
-		    ].
+        previousGroup := WindowGroup activeGroup.
+
+        "
+         show a stop-cursor in the main group
+        "
+        mainGroup notNil ifTrue:[
+            self isPopUpView ifFalse:[
+                mainGroup showCursor:(Cursor stop).
+                (previousGroup notNil and:[previousGroup ~~ mainGroup]) ifTrue:[
+                    previousGroup showCursor:(Cursor stop).
+                ].
+            ]
+        ].
+
+        "
+         create a new window group and put myself into it
+        "
+        windowGroup := WindowGroup new.
+        windowGroup addTopView:self.
+        windowGroup setPreviousGroup:previousGroup.
+
+        superView notNil ifTrue:[
+            "/
+            "/ special: this is a modal subview,
+            "/ prevent the view from reassigning its windowGroup when realized
+            "/ (subviews normally place themself into the superviews group)
+            "/        
+            windowGroup isForModalSubview:true.
+        ].
+
+        "
+         go dispatch events in this new group
+         (thus current windowgroup is blocked from interaction)
+        "
+        AbortSignal handle:[:ex |
+            self hide.
+            ex return.
+        ] do:[
+            [
+                [
+                    windowGroup startupModal:[realized and:aBlock] forGroup:mainGroup
+                ] valueOnUnwindDo:[
+                    self hide.
+                ]
+            ] ensure:[
+                mainGroup notNil ifTrue:[
+                    mainGroup graphicsDevice sync.
+                    "/ ensure that eventListener runs here ...
+                    Delay waitForSeconds:0.05.    
+                    mainGroup processExposeEvents.
+
+                    ReturnFocusWhenClosingModalBoxes ifTrue:[
+                        "
+                         return input focus to previously active groups top.
+                         This helps with windowmanagers which need an explicit click
+                         on the view for the focus.
+                        "
+                        tops := mainGroup topViews.
+                        (tops notNil and:[tops notEmpty]) ifTrue:[
+                            tops first getKeyboardFocus
+                        ].
+                    ].
+
+                    "
+                     restore cursors in the main group & flush its buffered key & mouse events
+                    "
+                    mainGroup restoreCursors.
+                    (previousGroup notNil and:[previousGroup ~~ mainGroup]) ifTrue:[
+                        previousGroup restoreCursors.
+                    ].
 "/                    mainGroup sensor flushUserEvents.
-		]
-	    ]
-	].
+                ]
+            ]
+        ].
     ]
 
     "Created: 10.12.1995 / 14:06:14 / cg"
@@ -9274,6 +9274,6 @@
 !SimpleView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.433 2002-02-25 20:00:34 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/SimpleView.st,v 1.434 2002-02-26 12:57:32 cg Exp $'
 ! !
 SimpleView initialize!
--- a/WindowGroup.st	Tue Feb 26 13:18:52 2002 +0100
+++ b/WindowGroup.st	Tue Feb 26 13:58:22 2002 +0100
@@ -1044,7 +1044,7 @@
                 [
                     startupAction value.
                     self eventLoopWhile:[true] onLeave:[]
-                ] valueNowOrOnUnwindDo:[
+                ] ensure:[
                     |dev|
 
                     (dev := self graphicsDevice) notNil ifTrue:[
@@ -1385,7 +1385,7 @@
                 ]
             ].
         ].
-    ] valueNowOrOnUnwindDo:[
+    ] ensure:[
         "/
         "/ perform any cleanupActions
         "/
@@ -1636,7 +1636,7 @@
                 ].
             ].
         ]
-    ] valueNowOrOnUnwindDo:[
+    ] ensure:[
         busyHookBlock notNil ifTrue:[
             Processor removeTimedBlock:busyHookBlock.
             busyHookBlock := nil.
@@ -2584,7 +2584,7 @@
 
     dev := self graphicsDevice.   
     (dev isNil or:[aCursor isNil]) ifTrue:[
-	^ aBlock value
+        ^ aBlock value
     ].
 
     deviceCursor := aCursor onDevice:dev.
@@ -2594,39 +2594,39 @@
     "
     oldCursors := IdentityDictionary new.
     self allViewsDo:[:aView |
-	|old|
-
-	old := aView cursor.
-	old ~~ aCursor ifTrue:[
-	    oldCursors at:aView put:old.
-	    aView cursor:deviceCursor now:false
-	]
+        |old|
+
+        old := aView cursor.
+        old ~~ aCursor ifTrue:[
+            oldCursors at:aView put:old.
+            aView cursor:deviceCursor now:false
+        ]
     ].
 
     oldCursors size == 0 ifTrue:[
-	action := aBlock
+        action := aBlock
     ] ifFalse:[
-	action := [
-		    |rslt|
-
-		    "/
-		    "/ here sync looks better; flush leads to almost invisible cursors when accepting.
-		    "/ I dont really know why (maybe unix does not context-switch to the Xserver
-		    "/ early enough after the requests have been sent ?)
-		    "/
-		    dev sync.
-
-		    rslt := aBlock valueNowOrOnUnwindDo:[
-			"
-			 restore cursors from the mapping
-			"
-			oldCursors keysAndValuesDo:[:view :cursor |
-			    view cursor:cursor now:false.
-			].
-			dev flush
-		    ].
-		    rslt
-		  ]
+        action := [
+                    |rslt|
+
+                    "/
+                    "/ here sync looks better; flush leads to almost invisible cursors when accepting.
+                    "/ I dont really know why (maybe unix does not context-switch to the Xserver
+                    "/ early enough after the requests have been sent ?)
+                    "/
+                    dev sync.
+
+                    rslt := aBlock ensure:[
+                        "
+                         restore cursors from the mapping
+                        "
+                        oldCursors keysAndValuesDo:[:view :cursor |
+                            view cursor:cursor now:false.
+                        ].
+                        dev flush
+                    ].
+                    rslt
+                  ]
     ].
 
 "/    (self isModal and:[previousGroup notNil]) ifTrue:[
@@ -2661,6 +2661,6 @@
 !WindowGroup class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.236 2001-11-19 16:44:15 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.237 2002-02-26 12:58:22 cg Exp $'
 ! !
 WindowGroup initialize!
--- a/WindowSensor.st	Tue Feb 26 13:18:52 2002 +0100
+++ b/WindowSensor.st	Tue Feb 26 13:58:22 2002 +0100
@@ -794,7 +794,7 @@
         ] do:[
             damageEventAccessLock critical:aBlock
         ]
-    ] valueNowOrOnUnwindDo:[
+    ] ensure:[
         wasBlocked ifFalse:[
             p unblockInterrupts.
         ]
@@ -814,11 +814,11 @@
     p := Processor activeProcess.
     wasBlocked := p blockInterrupts.
     [
-	userEventAccessLock critical:aBlock
-    ] valueNowOrOnUnwindDo:[
-	wasBlocked ifFalse:[
-	    p unblockInterrupts.
-	]
+        userEventAccessLock critical:aBlock
+    ] ensure:[
+        wasBlocked ifFalse:[
+            p unblockInterrupts.
+        ]
     ]
 
     "Created: / 6.6.1998 / 21:06:43 / cg"
@@ -3099,7 +3099,7 @@
                 ]
             ]
         ].
-    ] valueNowOrOnUnwindDo:[
+    ] ensure:[
         gotExpose remove:aView ifAbsent:nil.
         catchExpose remove:aView ifAbsent:nil.
         catchExpose isEmpty ifTrue:[
@@ -3136,6 +3136,6 @@
 !WindowSensor class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WindowSensor.st,v 1.200 2002-02-11 10:56:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WindowSensor.st,v 1.201 2002-02-26 12:58:10 cg Exp $'
 ! !
 WindowSensor initialize!