]> gitweb.factorcode.org Git - factor.git/commitdiff
ui: better handling of cascading errors
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 27 Jun 2017 21:02:25 +0000 (23:02 +0200)
committerBjörn Lindqvist <bjourne@gmail.com>
Tue, 27 Jun 2017 21:47:35 +0000 (23:47 +0200)
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.

basis/ui/backend/backend.factor
basis/ui/backend/gtk/gtk.factor
basis/ui/gadgets/worlds/worlds.factor
basis/ui/ui.factor

index c8e55228f3687b480e35df42336142ddfc390396..708ff0e1e40fa53e6fb7f5263790a89d6382fa9e 100644 (file)
@@ -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
index 6af7d43aa380e7381deada789a9d09e277adf7b2..31e4aac7dd788aff4c10b122cfd5f0d9b6cb8ad8 100644 (file)
@@ -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
index a4d092f0aa4b5cbfd81e9ed45a6b8fea6d960efd..84effed4bfc086be2bb88483c597b76cc1165af5 100644 (file)
@@ -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 ;
index 579da9b133fffe32c95caaeba9a32ba8a412a6bf..f74f96c5e855067cab3b224a1692646fcd703841 100644 (file)
@@ -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 ( -- )