#valueNowOrOnUnwindDo: -> #ensure:
authorClaus Gittinger <cg@exept.de>
Tue, 26 Feb 2002 14:03:47 +0100
changeset 3605 b5c70808fc8c
parent 3604 e32b5044a59e
child 3606 aeed73d9beb3
#valueNowOrOnUnwindDo: -> #ensure:
Image.st
ImageReader.st
--- a/Image.st	Tue Feb 26 13:58:22 2002 +0100
+++ b/Image.st	Tue Feb 26 14:03:47 2002 +0100
@@ -1300,19 +1300,19 @@
 
     inStream := Smalltalk systemFileStreamFor:name.
     inStream isNil ifTrue:[
-	inStream := Smalltalk bitmapFileStreamFor:name.
-	inStream isNil ifTrue:[
-
-	    "/ this signal is a query - if noone seems to
-	    "/ care, return nil.
-	    "/ However, a handler may provide a replacement.
+        inStream := Smalltalk bitmapFileStreamFor:name.
+        inStream isNil ifTrue:[
+
+            "/ this signal is a query - if noone seems to
+            "/ care, return nil.
+            "/ However, a handler may provide a replacement.
 
 "/            ('IMAGE: ' , aFileName , ' does not exist or is not readable') infoPrintCR.
-	    ^ ImageNotFoundQuerySignal
-			raiseRequestWith:aFileName
-			errorString:('IMAGE [warning]: ''' , aFileName asFilename pathName, ''' does not exist or is not readable').
-	].
-	name := 'bitmaps/' , name.
+            ^ ImageNotFoundQuerySignal
+                        raiseRequestWith:aFileName
+                        errorString:('IMAGE [warning]: ''' , aFileName asFilename pathName, ''' does not exist or is not readable').
+        ].
+        name := 'bitmaps/' , name.
     ].
     inStream notNil ifTrue:[pathName := inStream pathName].
     inStream close.
@@ -1325,14 +1325,14 @@
     "/ handle compressed-suffix
     "/
     (#('Z' 'gz') includes:suffix) ifTrue:[
-	fn := fn withoutSuffix.
-	nm := fn name.
-	suffix := fn suffix.
-	mustDecompress := true.
+        fn := fn withoutSuffix.
+        nm := fn name.
+        suffix := fn suffix.
+        mustDecompress := true.
     ].
 
     suffix isEmpty ifTrue:[
-	suffix := nm.
+        suffix := nm.
     ].
 
     "/ get the imageReader class from the files extension
@@ -1340,26 +1340,26 @@
 
     readerClass := MIMETypes imageReaderForSuffix:suffix.
     readerClass notNil ifTrue:[
-	mustDecompress == true ifTrue:[
-	    inPipe := PipeStream readingFrom:'gunzip <' , pathName.
-	    inPipe notNil ifTrue:[
-		[
-		    image := readerClass fromStream:inPipe.
-		] valueNowOrOnUnwindDo:[
-		    inPipe close
-		].
-		image notNil ifTrue:[^ image].
-	    ]
-	] ifFalse:[
-	    BadImageFormatQuerySignal handle:[:ex |
-		(readersErrorMsg := ex errorString) infoPrintCR.
-		image := nil.
-		ex return.
-	    ] do:[
-		image := readerClass fromFile:name.
-	    ].
-	    image notNil ifTrue:[^ image].
-	]
+        mustDecompress == true ifTrue:[
+            inPipe := PipeStream readingFrom:'gunzip <' , pathName.
+            inPipe notNil ifTrue:[
+                [
+                    image := readerClass fromStream:inPipe.
+                ] ensure:[
+                    inPipe close
+                ].
+                image notNil ifTrue:[^ image].
+            ]
+        ] ifFalse:[
+            BadImageFormatQuerySignal handle:[:ex |
+                (readersErrorMsg := ex errorString) infoPrintCR.
+                image := nil.
+                ex return.
+            ] do:[
+                image := readerClass fromFile:name.
+            ].
+            image notNil ifTrue:[^ image].
+        ]
     ].
 
     "
@@ -1369,15 +1369,15 @@
      therefore, it takes a bit longer.
     "
     MIMETypes imageReaderClasses do:[:mimeReaderClass |
-	(mimeReaderClass notNil 
-	and:[mimeReaderClass ~~ readerClass]) ifTrue:[
-	   (mimeReaderClass isValidImageFile:name) ifTrue:[
-		image := mimeReaderClass fromFile:name.
-		image notNil ifTrue:[
-		    ^ image
-		]
-	    ]
-	]
+        (mimeReaderClass notNil 
+        and:[mimeReaderClass ~~ readerClass]) ifTrue:[
+           (mimeReaderClass isValidImageFile:name) ifTrue:[
+                image := mimeReaderClass fromFile:name.
+                image notNil ifTrue:[
+                    ^ image
+                ]
+            ]
+        ]
     ].
 
     "/ nope - unknown format
@@ -1388,8 +1388,8 @@
 
 "/    'IMAGE: unknown image file format: ' infoPrint. aFileName infoPrintNL.
     ^ ImageNotFoundQuerySignal
-		raiseRequestWith:aFileName                                                                                            
-		errorString:(readersErrorMsg ? ('IMAGE [warning]: unknown image file format: ''' , aFileName asFilename pathName , '''')).
+                raiseRequestWith:aFileName                                                                                            
+                errorString:(readersErrorMsg ? ('IMAGE [warning]: unknown image file format: ''' , aFileName asFilename pathName , '''')).
 
     "
      Image fromFile:'goodies/bitmaps/gifImages/claus.gif'
@@ -1408,10 +1408,10 @@
 
      Image imageNotFoundQuerySignal 
      handle:[:ex |
-	Transcript showCR:ex errorString.
-	ex proceedWith:nil
+        Transcript showCR:ex errorString.
+        ex proceedWith:nil
      ] do:[
-	 Image fromFile:'fooBar'
+         Image fromFile:'fooBar'
      ]
     "
 
@@ -1420,7 +1420,7 @@
      Image imageNotFoundQuerySignal 
      answer:(Image fromFile:'bitmaps/SmalltalkX.xbm')
      do:[
-	 Image fromFile:'fooBar'
+         Image fromFile:'fooBar'
      ]
     "
 
@@ -12334,8 +12334,8 @@
      (especially True- and DirectColor may be wrong).
      Late note: 24bit rgb now also works.
      WARNING: with doGrab true, this temporarily grabs the display
-	      and it may not work from within a buttonMotion
-	      (use with a false grabArg then)."
+              and it may not work from within a buttonMotion
+              (use with a false grabArg then)."
 
     |curs cid rootView prevGrab|
 
@@ -12353,22 +12353,22 @@
     "
     rootView := aDevice rootView.
     doGrab ifTrue:[
-	prevGrab := aDevice activePointerGrab.
-	aDevice grabPointerInView:rootView withCursor:curs. 
+        prevGrab := aDevice activePointerGrab.
+        aDevice grabPointerInView:rootView withCursor:curs. 
     ].
 
     "
      get the pixels
     "
     [
-	self from:rootView in:aRectangle.
-    ] valueNowOrOnUnwindDo:[
-	doGrab ifTrue:[
-	    aDevice ungrabPointer.
-	    prevGrab notNil ifTrue:[
-		 aDevice grabPointerInView:prevGrab.
-	    ]
-	]
+        self from:rootView in:aRectangle.
+    ] ensure:[
+        doGrab ifTrue:[
+            aDevice ungrabPointer.
+            prevGrab notNil ifTrue:[
+                 aDevice grabPointerInView:prevGrab.
+            ]
+        ]
     ]
 
     "
@@ -12453,6 +12453,6 @@
 !Image class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.315 2001-11-28 13:24:51 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Image.st,v 1.316 2002-02-26 13:03:47 cg Exp $'
 ! !
 Image initialize!
--- a/ImageReader.st	Tue Feb 26 13:58:22 2002 +0100
+++ b/ImageReader.st	Tue Feb 26 14:03:47 2002 +0100
@@ -1655,7 +1655,7 @@
     ].
     [
         reader := self new fromStream:inStream.
-    ] valueNowOrOnUnwindDo:[
+    ] ensure:[
         inStream close.
     ].
     ^ reader
@@ -2150,5 +2150,5 @@
 !ImageReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.75 2001-09-13 09:01:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.76 2002-02-26 13:03:36 cg Exp $'
 ! !