From 52a64f70b45e8a10c4a3480f55f6ec6dd7ce1de6 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Thu, 30 Jan 2020 09:36:43 +0100 Subject: Prevent state corruption in runWhileEventsPending; wrap in withPossibleCallback --- src/Gtk/State.icl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Gtk/State.icl b/src/Gtk/State.icl index 32c2b19..fde5cf0 100644 --- a/src/Gtk/State.icl +++ b/src/Gtk/State.icl @@ -109,10 +109,12 @@ quit :: GtkM () quit = modState (\st -> {st & return=True}) >>| pure () runWhileEventsPending :: GtkM () -runWhileEventsPending = - toStateR gtk_events_pending >>= \pending - | not pending -> - pure () - | otherwise -> - toStateR gtk_main_iteration >>| - runWhileEventsPending +runWhileEventsPending = withPossibleCallback run +where + run = + toStateR gtk_events_pending >>= \pending + | not pending -> + pure () + | otherwise -> + toStateR gtk_main_iteration >>| + run -- cgit v1.2.3