]> gitweb.factorcode.org Git - factor.git/commitdiff
windows.dropfiles: remove an exception suppression
authorAlexander Iljin <ajsoft@yandex.ru>
Sat, 20 Jan 2018 21:12:07 +0000 (22:12 +0100)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 22 Jan 2018 21:09:41 +0000 (13:09 -0800)
Instead of suppressing all exceptions make a specific check for the
function avalability.

basis/windows/dropfiles/dropfiles.factor

index 1080dbbebf13d9747efd0218651cf4302b9b1593..b25b4d33423d5c9649a149f51d8ab4d92d3747b3 100644 (file)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2017 Alexander Ilin.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien alien.data alien.strings continuations
-fry io.encodings.utf16n kernel literals math namespaces
-sequences ui.backend.windows ui.gadgets.worlds ui.gestures
-windows.messages windows.shell32 windows.types windows.user32 ;
+USING: accessors alien alien.data alien.libraries alien.strings
+continuations fry io.encodings.utf16n kernel literals math
+namespaces sequences ui.backend.windows ui.gadgets.worlds
+ui.gestures windows.messages windows.shell32 windows.types
+windows.user32 ;
 IN: windows.dropfiles
 
 : filecount-from-hdrop ( hdrop -- n )
@@ -29,17 +30,16 @@ IN: windows.dropfiles
 ! list of wm-handlers. Therefore, there is no benefit in using the stricter
 ! ChangeWindowMessageFilterEx approach. Plus, the latter is not in Vista.
 : (init-message-filter) ( -- )
-    ${ WM_DROPFILES WM_COPYDATA WM_COPYGLOBALDATA }
-    [ MSGFLT_ADD ChangeWindowMessageFilter win32-error=0/f ] each ;
+    "ChangeWindowMessageFilter" "user32" dlsym? [
+        ${ WM_DROPFILES WM_COPYDATA WM_COPYGLOBALDATA }
+        [ MSGFLT_ADD ChangeWindowMessageFilter win32-error=0/f ] each
+    ] when ;
 
 : do-once ( guard-variable quot -- )
     dupd '[ t _ set-global @ ] [ get-global ] dip unless ; inline
 
-! Ignore the errors: on WinXP the function is missing, and is not needed.
 : init-message-filter ( -- )
-    \ init-message-filter [
-        [ (init-message-filter) ] [ drop ] recover
-    ] do-once ;
+    \ init-message-filter [ (init-message-filter) ] do-once ;
 
 : install-wm-handler ( -- )
     [ drop 2nip handle-wm-dropfiles 0 ] WM_DROPFILES add-wm-handler ;