diff options
author | Robin Gareus <robin@gareus.org> | 2016-07-25 14:13:52 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-07-25 14:13:52 +0200 |
commit | 3953879d4d423e3d7f79b1913b4ff6fe502c6542 (patch) | |
tree | b275c3bcc8e3b763c0776eb66c8879d43313eda0 /libs/gtkmm2ext/gtk_ui.cc | |
parent | 42b20f15a2e5d751582f4c467ffcbcbc9b71a59c (diff) |
add a timeout to flush_pending()
In some circumstances UI::flush_pending never returns, and all UI
interactive ends up being driven by
while (gtk_events_pending()) { gtk_main_iteration(); }
This has various implications depending on the caller and usually results
in a crash at session-close or exit.
Diffstat (limited to 'libs/gtkmm2ext/gtk_ui.cc')
-rw-r--r-- | libs/gtkmm2ext/gtk_ui.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libs/gtkmm2ext/gtk_ui.cc b/libs/gtkmm2ext/gtk_ui.cc index c3e94c922e..c96c31b3de 100644 --- a/libs/gtkmm2ext/gtk_ui.cc +++ b/libs/gtkmm2ext/gtk_ui.cc @@ -728,7 +728,7 @@ UI::popup_error (const string& text) } void -UI::flush_pending () +UI::flush_pending (float timeout) { if (!caller_is_ui_thread()) { error << "non-UI threads cannot call UI::flush_pending()" @@ -736,9 +736,15 @@ UI::flush_pending () return; } + int64_t end = g_get_monotonic_time () + timeout * 1e6; + gtk_main_iteration(); while (gtk_events_pending()) { + if (timeout > 0 && end < g_get_monotonic_time ()) { + cerr << "UI::flush_pending timed out after " << timeout << "s.\n"; + break; + } gtk_main_iteration(); } } |