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
parent
b7727bc695
commit
2aa1a3dbd7
|
@ -91,6 +91,9 @@ TUPLE: run-loop fds sources timers ;
|
||||||
CFRunLoopAddTimer
|
CFRunLoopAddTimer
|
||||||
] bi ;
|
] bi ;
|
||||||
|
|
||||||
|
: invalidate-run-loop-timers ( -- )
|
||||||
|
run-loop [ [ [ CFRunLoopTimerInvalidate ] [ CFRelease ] bi ] each V{ } ] change-timers drop ;
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: ((reset-timer)) ( timer counter timestamp -- )
|
: ((reset-timer)) ( timer counter timestamp -- )
|
||||||
|
|
|
@ -214,6 +214,7 @@ M: cocoa-ui-backend beep ( -- )
|
||||||
NSBeep ;
|
NSBeep ;
|
||||||
|
|
||||||
M: cocoa-ui-backend system-alert
|
M: cocoa-ui-backend system-alert
|
||||||
|
invalidate-run-loop-timers
|
||||||
NSAlert -> alloc -> init -> autorelease [
|
NSAlert -> alloc -> init -> autorelease [
|
||||||
{
|
{
|
||||||
[ swap <NSString> -> setInformativeText: ]
|
[ swap <NSString> -> setInformativeText: ]
|
||||||
|
@ -221,7 +222,8 @@ M: cocoa-ui-backend system-alert
|
||||||
[ "OK" <NSString> -> addButtonWithTitle: drop ]
|
[ "OK" <NSString> -> addButtonWithTitle: drop ]
|
||||||
[ -> runModal drop ]
|
[ -> runModal drop ]
|
||||||
} cleave
|
} cleave
|
||||||
] [ 2drop ] if* ;
|
] [ 2drop ] if*
|
||||||
|
init-thread-timer ;
|
||||||
|
|
||||||
CLASS: {
|
CLASS: {
|
||||||
{ +superclass+ "NSObject" }
|
{ +superclass+ "NSObject" }
|
||||||
|
|
Loading…
Reference in New Issue