From 6788ff5967508056d1321c16143bf72fa7cd4516 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 3 Sep 2014 00:28:35 +0100 Subject: Speculative fix for Doremi certificate download on OS X. The while (wxTheApp->Pending ()) wxTheApp->Dispatch() appears to hang on OS X. --- src/lib/ui_signaller.h | 7 +++++++ src/wx/doremi_certificate_dialog.cc | 13 ++++++++++++- src/wx/doremi_certificate_dialog.h | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/ui_signaller.h b/src/lib/ui_signaller.h index 1d62547f6..ee4d230d4 100644 --- a/src/lib/ui_signaller.h +++ b/src/lib/ui_signaller.h @@ -54,8 +54,15 @@ public: } } + /* Do something next time the UI is idle */ + template + void when_idle (T f) { + _service.post (f); + } + /** Call this in the UI when it is idle */ size_t ui_idle () { + /* This executes any functors that have been post()ed to _service */ return _service.poll (); } diff --git a/src/wx/doremi_certificate_dialog.cc b/src/wx/doremi_certificate_dialog.cc index b4cd14eaf..4b5d58b37 100644 --- a/src/wx/doremi_certificate_dialog.cc +++ b/src/wx/doremi_certificate_dialog.cc @@ -21,6 +21,7 @@ #include #include "lib/compose.hpp" #include "lib/util.h" +#include "lib/ui_signaller.h" #include "lib/internet.h" #include "doremi_certificate_dialog.h" #include "wx_util.h" @@ -51,8 +52,18 @@ DoremiCertificateDialog::download () } _message->SetLabel (_("Downloading certificate")); - run_gui_loop (); +#ifdef DCPOMATIC_OSX + /* This is necessary on OS X, otherwise the SetLabel() above has no visible effect */ + wxMilliSleep (200); +#endif + + ui_signaller->when_idle (boost::bind (&DoremiCertificateDialog::finish_download, this, serial)); +} + +void +DoremiCertificateDialog::finish_download (string serial) +{ /* Try dcp2000, imb and ims prefixes (see mantis #375) */ optional error = get_from_zip_url ( diff --git a/src/wx/doremi_certificate_dialog.h b/src/wx/doremi_certificate_dialog.h index 281184726..b249736ec 100644 --- a/src/wx/doremi_certificate_dialog.h +++ b/src/wx/doremi_certificate_dialog.h @@ -28,5 +28,7 @@ private: void download (); void set_sensitivity (); + void finish_download (std::string serial); + wxTextCtrl* _serial; }; -- cgit v1.2.3