]> gitweb.factorcode.org Git - factor.git/commitdiff
windows.gdiplus: call GdiplusStartup and GdiplusShutdown in startup/shutdown hooks
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 24 Jan 2022 23:27:11 +0000 (15:27 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 24 Jan 2022 23:27:11 +0000 (15:27 -0800)
basis/images/loader/gdiplus/gdiplus.factor
basis/windows/gdiplus/gdiplus.factor

index 0f4835e683b74c47205a687483031d57b846ca87..943e5cc29f6d1fed41c8acda605b64104311ee64 100644 (file)
@@ -88,9 +88,6 @@ ERROR: unsupported-pixel-format component-order ;
 : mime-type>clsid ( mime-type -- clsid )
     image-encoders [ MimeType>> alien>native-string = ] with find nip Clsid>> ;
 
-: startup-gdi+ ( -- )
-    start-gdi+ &stop-gdi+ drop ;
-
 : write-image-to-stream ( image stream extension -- )
     [ image>gdi+-bitmap ]
     [ stream>IStream &com-release ]
@@ -100,10 +97,10 @@ ERROR: unsupported-pixel-format component-order ;
 PRIVATE>
 
 M: gdi+-image stream>image*
-    drop startup-gdi+
+    drop
     stream>gdi+-bitmap
     gdi+-bitmap>data
     data>image ;
 
 M: gdi+-image image>stream
-    drop startup-gdi+ output-stream get swap write-image-to-stream ;
+    drop output-stream get swap write-image-to-stream ;
index 83d285b0def3dbe306569038e2a53ba58b2f5093..e9593d5768555a81f87e746e651b5772453b1b66 100644 (file)
@@ -1648,3 +1648,8 @@ CONSTANT: standard-gdi+-startup-input
     GdiplusShutdown ;
 
 DESTRUCTOR: stop-gdi+
+
+SYMBOL: gdi-token
+
+[ start-gdi+ gdi-token set-global ] "windows.gdiplus" add-startup-hook
+[ gdi-token get-global [ stop-gdi+ ] when* ] "windows.gdiplus" add-shutdown-hook