]> gitweb.factorcode.org Git - factor.git/commitdiff
images: gdiplus had a resource leak (file descriptor). change stream>image to dispose...
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 25 Aug 2012 18:44:40 +0000 (11:44 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 25 Aug 2012 18:44:40 +0000 (11:44 -0700)
stream no matter what.

12 files changed:
basis/images/loader/cocoa/cocoa.factor
basis/images/loader/gdiplus/gdiplus.factor
basis/images/loader/gtk/gtk.factor
basis/images/loader/loader.factor
extra/images/bitmap/bitmap.factor
extra/images/gif/gif.factor
extra/images/pbm/pbm.factor
extra/images/pgm/pgm.factor
extra/images/png/png.factor
extra/images/ppm/ppm.factor
extra/images/tga/tga.factor
extra/images/tiff/tiff.factor

index 6680a4f317b3300b1e06070931eb9c6d250b1615..b3d05999f939b2007189c256e9ad010be8d6f669 100644 (file)
@@ -33,5 +33,5 @@ os macosx? [
         0 0 w h <CGRect> image CGContextDrawImage
     ] make-bitmap-image ;
 
-M: ns-image stream>image
+M: ns-image stream>image*
     drop stream-contents <CGImage> CGImage>image ;
index 3ac0e2accf79c73eaf1919ddf8d85b8b1b8f02bf..5ef2bd05ca1608e3c0ef224593c1baa2facadb0b 100644 (file)
@@ -57,10 +57,9 @@ os windows? [
 \r
 PRIVATE>\r
 \r
-M: gdi+-image stream>image\r
-    drop [\r
-        start-gdi+ &stop-gdi+ drop\r
-        stream>gdi+-bitmap\r
-        gdi+-bitmap>data\r
-        data>image\r
-    ] with-destructors ;\r
+M: gdi+-image stream>image*\r
+    drop\r
+    start-gdi+ &stop-gdi+ drop\r
+    stream>gdi+-bitmap\r
+    gdi+-bitmap>data\r
+    data>image ;\r
index 1cf39e688581cb2ee3156a66237e8fef84649473..69ec5f89749b61820bbc746442471c6454a216f9 100644 (file)
@@ -64,9 +64,8 @@ os linux? [
 
 PRIVATE>
 
-M: gtk-image stream>image
-    drop [
-        stream-contents data>GInputStream &g_object_unref
-        GInputStream>GdkPixbuf &g_object_unref
-        GdkPixbuf>image
-    ] with-destructors ;
+M: gtk-image stream>image*
+    drop
+    stream-contents data>GInputStream &g_object_unref
+    GInputStream>GdkPixbuf &g_object_unref
+    GdkPixbuf>image ;
index 7be8300f636e5b2da83da9c8bbae180cda62d4eb..6bd5d54a287aecd506cc05ca0511c0b84864bf48 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Doug Coleman, Daniel Ehrenberg.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: ascii assocs byte-arrays io.encodings.binary io.files
-io.pathnames io.streams.byte-array kernel namespaces sequences
-strings fry ;
+USING: ascii assocs byte-arrays destructors fry
+io.encodings.binary io.files io.pathnames io.streams.byte-array
+kernel namespaces sequences strings ;
 IN: images.loader
 
 ERROR: unknown-image-extension extension ;
@@ -24,7 +24,10 @@ PRIVATE>
 
 GENERIC# load-image* 1 ( obj class -- image )
 
-GENERIC: stream>image ( stream class -- image )
+GENERIC: stream>image* ( stream class -- image )
+
+: stream>image ( stream class -- image )
+    '[ _ &dispose _ stream>image* ] with-destructors ; inline
 
 : register-image-class ( extension class -- )
     swap types get set-at ;
index 01c9ba00a9575a27a15fb5bb5447a6a1d66789a8..f637dca9879cf4994c0791365a86c37176f44476 100644 (file)
@@ -370,7 +370,7 @@ ERROR: unsupported-bitmap-file magic ;
 : loading-bitmap>bytes ( loading-bitmap -- byte-array )
     uncompress-bitmap bitmap>bytes ;
 
-M: bmp-image stream>image ( stream bmp-image -- bitmap )
+M: bmp-image stream>image* ( stream bmp-image -- bitmap )
     drop load-bitmap
     [ image new ] dip
     {
index 92ed3cd995505cb4a43ca5c61c7a438efa52fcf8..25776bffdd949732247a422ededef5a6fde9855b 100644 (file)
@@ -248,5 +248,5 @@ ERROR: loading-gif-error gif-image ;
 : ensure-loaded ( gif-image -- gif-image )
     dup loading?>> [ loading-gif-error ] when ;
 
-M: gif-image stream>image ( path gif-image -- image )
+M: gif-image stream>image* ( path gif-image -- image )
     drop load-gif ensure-loaded gif>image ;
index a6e7edb9e2dc1cf84c272cd1c73a93c72c1eff7c..35e14cc9a6790cea9232b9227dd35fc4491c4a89 100644 (file)
@@ -72,7 +72,7 @@ SINGLETON: pbm-image
     ubyte-components >>component-type ;
 PRIVATE>
 
-M: pbm-image stream>image
+M: pbm-image stream>image*
     drop [ [ read-pbm ] throw-on-eof ] with-input-stream ;
 
 M: pbm-image image>stream
index 4457c8913539c2207a51b6c87827b2b9686dfd62..d8e1033c903ef6cb527520d3bb98afafce6b163e 100644 (file)
@@ -49,7 +49,7 @@ SINGLETON: pgm-image
     data                                               >>bitmap
     wide [ ushort-components ] [ ubyte-components ] if >>component-type ;
 
-M: pgm-image stream>image
+M: pgm-image stream>image*
     drop [ [ read-pgm ] throw-on-eof ] with-input-stream ;
 
 M: pgm-image image>stream
index f98eeedd77b74da8291c2b45dff3ec37a995cb1d..ac608208783cf06a384555c93d8af3d9b499802e 100644 (file)
@@ -357,5 +357,5 @@ ERROR: invalid-color-type/bit-depth loading-png ;
         ] throw-on-eof
     ] with-input-stream ;
 
-M: png-image stream>image
+M: png-image stream>image*
     drop load-png loading-png>image ;
index 454a4b34f579599301d5cfc3495b8d31ae9d89ef..865f377fbce87586e0d1a980f0b49042287ecf1f 100755 (executable)
@@ -46,7 +46,7 @@ SINGLETON: ppm-image
     data             >>bitmap
     ubyte-components >>component-type ;
 
-M: ppm-image stream>image
+M: ppm-image stream>image*
     drop [ [ read-ppm ] throw-on-eof ] with-input-stream ;
 
 M: ppm-image image>stream
index efdcbc537c7295ec2ffa951cb153787215affa12..f2fd8e86606fd80d2b6c5ea0033d1fa28b3d3772 100644 (file)
@@ -253,7 +253,7 @@ ERROR: bad-tga-unsupported ;
     image-data                         >>bitmap
     ubyte-components                   >>component-type ;
     
-M: tga-image stream>image
+M: tga-image stream>image*
     drop [ [ read-tga ] throw-on-eof ] with-input-stream ;
 
 M: tga-image image>stream
index c8a3f76353663b05addbf3eff3db98444b016d6d..2a6e184a3b31843f7240d727dc3e27eb250143e5 100755 (executable)
@@ -560,7 +560,7 @@ ERROR: unknown-component-order ifd ;
     [ process-tif-ifds ] with-tiff-endianness ;
 
 ! tiff files can store several images -- we just take the first for now
-M: tiff-image stream>image ( stream tiff-image -- image )
+M: tiff-image stream>image* ( stream tiff-image -- image )
     drop [ [ load-tiff tiff>image ] throw-on-eof ] with-input-stream ;
 
 { "tif" "tiff" } [ tiff-image register-image-class ] each