ui: better handling of cascading errors
The second update-ui is wrapped in a recover so that if it fails again, the UI system is stopped. That should fix the cascade problem in #1827.modern-harvey2
parent
f718269d50
commit
fe41e99437
|
@ -35,4 +35,9 @@ HOOK: ui-backend-available? ui-backend ( -- ? )
|
|||
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
|
||||
|
|
|
@ -513,6 +513,9 @@ M: gtk-ui-backend (with-ui)
|
|||
] with-destructors
|
||||
] ui-running ;
|
||||
|
||||
M: gtk-ui-backend stop-event-loop
|
||||
gtk_main_quit ;
|
||||
|
||||
os linux? [
|
||||
gtk-ui-backend ui-backend set-global
|
||||
] when
|
||||
|
|
|
@ -217,7 +217,7 @@ ui-error-hook [ [ rethrow ] ] initialize
|
|||
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 ;
|
||||
|
|
|
@ -76,8 +76,7 @@ SYMBOL: ui-windows
|
|||
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 -- )
|
||||
|
@ -152,14 +151,18 @@ PRIVATE>
|
|||
<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 ( -- )
|
||||
|
|
Loading…
Reference in New Issue