If (open-window) or similar fails, don't enter an infinite loop of opening error windows, just try to open one and then give up

db4
Slava Pestov 2009-04-07 22:30:13 -05:00
parent ba61b82152
commit 6082a98c7c
1 changed files with 17 additions and 14 deletions

View File

@ -2,9 +2,9 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: arrays assocs io kernel math models namespaces make dlists USING: arrays assocs io kernel math models namespaces make dlists
deques sequences threads sequences words continuations init deques sequences threads sequences words continuations init
combinators hashtables concurrency.flags sets accessors calendar fry combinators combinators.short-circuit hashtables concurrency.flags
destructors ui.gadgets ui.gadgets.private ui.gadgets.worlds sets accessors calendar fry destructors ui.gadgets ui.gadgets.private
ui.gadgets.tracks ui.gestures ui.backend ui.render ; ui.gadgets.worlds ui.gadgets.tracks ui.gestures ui.backend ui.render ;
IN: ui IN: ui
<PRIVATE <PRIVATE
@ -117,12 +117,10 @@ M: world ungraft*
gesture-queue [ send-queued-gesture notify-queued ] slurp-deque ; gesture-queue [ send-queued-gesture notify-queued ] slurp-deque ;
: update-ui ( -- ) : update-ui ( -- )
[ notify-queued
notify-queued layout-queued
layout-queued redraw-worlds
redraw-worlds send-queued-gestures ;
send-queued-gestures
] [ ui-error ] recover ;
SYMBOL: ui-thread SYMBOL: ui-thread
@ -133,8 +131,7 @@ SYMBOL: ui-thread
PRIVATE> PRIVATE>
: find-window ( quot -- world ) : find-window ( quot -- world )
windows get values [ windows get values ] dip '[ gadget-child @ ] find-last nip ; inline
[ gadget-child swap call ] with find-last nip ; inline
: ui-running? ( -- ? ) : ui-running? ( -- ? )
\ ui-running get-global ; \ ui-running get-global ;
@ -142,9 +139,15 @@ PRIVATE>
<PRIVATE <PRIVATE
: update-ui-loop ( -- ) : update-ui-loop ( -- )
[ ui-running? ui-thread get-global self eq? and ] #! Note the logic: if update-ui fails, we open an error window
[ ui-notify-flag get lower-flag update-ui ] #! and run one iteration of update-ui. If that also fails, well,
while ; #! the whole UI subsystem is broken so we exit out of the
#! update-ui-loop.
[ { [ ui-running? ] [ ui-thread get-global self eq? ] } 0&& ]
[
ui-notify-flag get lower-flag
[ update-ui ] [ ui-error update-ui ] recover
] while ;
: start-ui-thread ( -- ) : start-ui-thread ( -- )
[ self ui-thread set-global update-ui-loop ] [ self ui-thread set-global update-ui-loop ]