]> gitweb.factorcode.org Git - factor.git/commitdiff
windows.dragdrop-listener: call ole-initialize when necessary
authorAlexander Iljin <ajsoft@yandex.ru>
Mon, 21 Aug 2017 00:08:55 +0000 (03:08 +0300)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 22 Jan 2018 21:09:41 +0000 (13:09 -0800)
This makes the code more robust and self-reliant.

basis/windows/dragdrop-listener/dragdrop-listener.factor

index 6a7d03d494101e809515074a94e34e8416d0195e..fb04ba5da83e7fd7a67ace661aa144c0aef4ffbc 100644 (file)
@@ -10,6 +10,8 @@ windows.shell32 windows.types ;
 SPECIALIZED-ARRAY: WCHAR
 IN: windows.dragdrop-listener
 
+CONSTANT: E_OUTOFMEMORY -2147024882 ! 0x8007000e
+
 : filecount-from-hdrop ( hdrop -- n )
     0xFFFFFFFF f 0 DragQueryFile ;
 
@@ -85,5 +87,8 @@ SYMBOL: +listener-dragdrop-wrapper+
 
 : dragdrop-listener-window ( -- )
     world get handle>> hWnd>> dup <listener-dragdrop>
-    +listener-dragdrop-wrapper+ get-global com-wrap
-    [ RegisterDragDrop check-ole32-error ] with-com-interface ;
+    +listener-dragdrop-wrapper+ get-global com-wrap [
+        2dup RegisterDragDrop dup E_OUTOFMEMORY =
+        [ drop ole-initialize RegisterDragDrop ] [ 2nip ] if
+        check-ole32-error
+    ] with-com-interface ;