]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.backend.cocoa: invalidate run loop timers before raising an NSAlert and add them...
authorJoe Groff <arcata@gmail.com>
Wed, 24 Feb 2010 07:50:34 +0000 (23:50 -0800)
committerJoe Groff <arcata@gmail.com>
Wed, 24 Feb 2010 07:52:03 +0000 (23:52 -0800)
basis/core-foundation/run-loop/run-loop.factor
basis/ui/backend/cocoa/cocoa.factor

index 2370dd45628dd47005409f8a897c8c6416033685..e2ba06d61fed3d1291df32c7936bf913a7934ccf 100644 (file)
@@ -91,6 +91,9 @@ TUPLE: run-loop fds sources timers ;
         CFRunLoopAddTimer
     ] bi ;
 
+: invalidate-run-loop-timers ( -- )
+    run-loop [ [ [ CFRunLoopTimerInvalidate ] [ CFRelease ] bi ] each V{ } ] change-timers drop ;
+
 <PRIVATE
 
 : ((reset-timer)) ( timer counter timestamp -- )
index 6e64c35e49e5ed73c1496f1989e1258d33e5c15a..d4f9b82cffad38911d7ab6dd95f132530754dd39 100644 (file)
@@ -214,6 +214,7 @@ M: cocoa-ui-backend beep ( -- )
     NSBeep ;
 
 M: cocoa-ui-backend system-alert
+    invalidate-run-loop-timers
     NSAlert -> alloc -> init -> autorelease [
         {
             [ swap <NSString> -> setInformativeText: ]
@@ -221,7 +222,8 @@ M: cocoa-ui-backend system-alert
             [ "OK" <NSString> -> addButtonWithTitle: drop ]
             [ -> runModal drop ]
         } cleave
-    ] [ 2drop ] if* ;
+    ] [ 2drop ] if*
+    init-thread-timer ;
 
 CLASS: {
     { +superclass+ "NSObject" }