From 62542c52a957ab5aeebb90a0aa698c0900bdac9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Mon, 29 Jan 2018 07:55:36 +0100 Subject: [PATCH] ui: try and ensure that the ui thread finishes #1905 --- basis/ui/ui-tests.factor | 9 +++++++++ basis/ui/ui.factor | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 basis/ui/ui-tests.factor diff --git a/basis/ui/ui-tests.factor b/basis/ui/ui-tests.factor new file mode 100644 index 0000000000..a480b4ab40 --- /dev/null +++ b/basis/ui/ui-tests.factor @@ -0,0 +1,9 @@ +USING: assocs kernel threads tools.test ui ; +IN: ui.tests + +{ t } [ + ! with-ui shouldn't leave any thread hanging around. + threads assoc-size + [ ] with-ui + threads assoc-size = +] unit-test diff --git a/basis/ui/ui.factor b/basis/ui/ui.factor index d23416ca19..43af6f6c81 100644 --- a/basis/ui/ui.factor +++ b/basis/ui/ui.factor @@ -224,7 +224,11 @@ M: object resize-window 2drop ; ui-running? [ call( -- ) ] [ t ui-running set-global '[ [ init-ui @ ] (with-ui) - ] [ f ui-running set-global ] [ ] cleanup + ] [ + f ui-running set-global + ! Give running ui threads a chance to finish. + notify-ui-thread yield + ] [ ] cleanup ] if ; HOOK: beep ui-backend ( -- )