ui.backend.cocoa: invalidate run loop timers before raising an NSAlert and add them back when runModal returns to avoid run loop callbacks reentering Factor

db4
Joe Groff 2010-02-23 23:50:34 -08:00
parent b7727bc695
commit 2aa1a3dbd7
2 changed files with 6 additions and 1 deletions

View 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 -- )

View 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" }