M: object ui-backend-available?
f ;
+HOOK: stop-event-loop ui-backend ( -- )
+
+M: object stop-event-loop
+ ;
+
[ ui-backend-available? "ui.tools" "listener" ? ] main-vocab-hook set-global
dup [ draw-world* ] with-gl-context
flush-layout-cache-hook get call( -- )
] [
- swap f >>active? <world-error> ui-error
+ swap f >>active? <world-error> throw
] recover
] with-variable
] [ drop ] if ;
M: world graft*
[ (open-window) ]
[
- [ set-up-window ]
- [ [ clean-up-broken-window ] [ ui-error ] bi* ] recover
+ [ set-up-window ] [ ] [ clean-up-broken-window ] cleanup
] bi ;
: dispose-window-resources ( world -- )
<PRIVATE
: update-ui-loop ( -- )
- ! Note the logic: if update-ui fails, we open an error window
- ! and run one iteration of update-ui. If that also fails, well,
- ! the whole UI subsystem is broken so we exit out of the
- ! update-ui-loop.
+ ! Note the logic: if update-ui fails, we open an error window and
+ ! run one iteration of update-ui. If that also fails, well, the
+ ! whole UI subsystem is broken so we throw the error to terminate
+ ! 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
+ [ update-ui ] [
+ [ ui-error update-ui ] [
+ stop-event-loop nip rethrow
+ ] recover
+ ] recover
] while ;
: start-ui-thread ( -- )