Merge branch 'master' of ssh://carlh.dyndns.org/home/carl/git/dcpomatic
[dcpomatic.git] / src / wx / wx_util.cc
index 103d36d006d1539043f8c357fae1ebdf98ceb0f7..96278b82bac0d1197a26ae68da601c9084a912a3 100644 (file)
@@ -140,11 +140,18 @@ ThreadedStaticText::~ThreadedStaticText ()
 /** Run our thread and post the result to the GUI thread via AddPendingEvent */
 void
 ThreadedStaticText::run (function<string ()> fn)
+try
 {
        wxCommandEvent ev (wxEVT_COMMAND_TEXT_UPDATED, _update_event_id);
        ev.SetString (std_to_wx (fn ()));
        GetEventHandler()->AddPendingEvent (ev);
 }
+catch (...)
+{
+       /* Ignore exceptions; marginally better than the program quitting, but
+          only marginally.
+       */
+}
 
 /** Called in the GUI thread when our worker thread has finished */
 void
@@ -289,3 +296,11 @@ wx_get (wxChoice* w)
 {
        return w->GetSelection ();
 }
+
+void
+run_gui_loop ()
+{
+       while (wxTheApp->Pending ()) {
+               wxTheApp->Dispatch ();
+       }
+}