diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-02-23 01:24:17 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-02-23 01:24:17 +0100 |
| commit | b5700cf59c12164b07550d8b217b98b1616227ab (patch) | |
| tree | 125ada25885e9f54c1e243348adb6fe2bb78e1d7 /src/tools | |
| parent | d3a3b8988fcc7df405b8d73a0aabd967ad7a8bf0 (diff) | |
Be more careful to always close the splash screen when necessary.
Trying to prevent error dialogues appearing behind it.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/dcpomatic.cc | 16 | ||||
| -rw-r--r-- | src/tools/dcpomatic_batch.cc | 19 | ||||
| -rw-r--r-- | src/tools/dcpomatic_kdm.cc | 32 | ||||
| -rw-r--r-- | src/tools/dcpomatic_player.cc | 26 | ||||
| -rw-r--r-- | src/tools/dcpomatic_server.cc | 25 |
5 files changed, 63 insertions, 55 deletions
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index be172ed2d..9b1280e3f 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -1553,8 +1553,6 @@ class App : public wxApp public: App () : wxApp () - , _frame (0) - , _splash (0) { #ifdef DCPOMATIC_LINUX XInitThreads (); @@ -1661,10 +1659,7 @@ private: } catch (exception& e) { - if (_splash) { - _splash->Destroy (); - _splash = nullptr; - } + close_splash (); error_dialog (nullptr, wxString::Format ("DCP-o-matic could not start."), std_to_wx(e.what())); } @@ -1778,7 +1773,7 @@ private: { if (_splash) { _splash->Destroy (); - _splash = 0; + _splash = nullptr; } } @@ -1799,8 +1794,7 @@ private: /* Destroy the splash screen here, as otherwise bad things seem to happen (for reasons unknown) when we open our recreate dialog, close it, *then* try to Destroy the splash (the Destroy fails). */ - _splash->Destroy (); - _splash = nullptr; + close_splash (); auto config = Config::instance(); switch (reason) { @@ -1859,8 +1853,8 @@ private: } } - DOMFrame* _frame; - wxSplashScreen* _splash; + DOMFrame* _frame = nullptr; + wxSplashScreen* _splash = nullptr; shared_ptr<wxTimer> _timer; string _film_to_load; string _film_to_create; diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 9cb6ddc55..73c931411 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -392,7 +392,7 @@ class App : public wxApp Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this)); Config::Warning.connect (boost::bind (&App::config_warning, this, _1)); - wxSplashScreen* splash = maybe_show_splash (); + _splash = maybe_show_splash (); if (!wxApp::OnInit()) { return false; @@ -425,9 +425,7 @@ class App : public wxApp _frame = new DOMFrame (_("DCP-o-matic Batch Converter")); SetTopWindow (_frame); _frame->Maximize (); - if (splash) { - splash->Destroy (); - } + close_splash (); _frame->Show (); JobServer* server = new JobServer (_frame); @@ -476,17 +474,28 @@ class App : public wxApp return true; } + void close_splash () + { + if (_splash) { + _splash->Destroy (); + _splash = 0; + } + } + void config_failed_to_load () { + close_splash (); message_dialog (_frame, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create.")); } void config_warning (string m) { + close_splash (); message_dialog (_frame, std_to_wx (m)); } - DOMFrame* _frame; + DOMFrame* _frame = nullptr; + wxSplashScreen* _splash = nullptr; }; IMPLEMENT_APP (App) diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index ee5e45457..67c28da52 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -615,25 +615,17 @@ private: */ class App : public wxApp { -public: - App () - : wxApp () - , _frame (0) - {} - private: bool OnInit () { - wxSplashScreen* splash = nullptr; - try { wxInitAllImageHandlers (); Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this)); Config::Warning.connect (boost::bind (&App::config_warning, this, _1)); - splash = maybe_show_splash (); + _splash = maybe_show_splash (); SetAppName (_("DCP-o-matic KDM Creator")); @@ -672,10 +664,7 @@ private: _frame = new DOMFrame (_("DCP-o-matic KDM Creator")); SetTopWindow (_frame); _frame->Maximize (); - if (splash) { - splash->Destroy (); - splash = 0; - } + close_splash (); _frame->Show (); signal_manager = new wxSignalManager (this); @@ -683,9 +672,7 @@ private: } catch (exception& e) { - if (splash) { - splash->Destroy (); - } + close_splash (); error_dialog (0, _("DCP-o-matic could not start"), std_to_wx(e.what())); } @@ -732,17 +719,28 @@ private: signal_manager->ui_idle (); } + void close_splash () + { + if (_splash) { + _splash->Destroy (); + _splash = 0; + } + } + void config_failed_to_load () { + close_splash (); message_dialog (_frame, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create.")); } void config_warning (string m) { + close_splash (); message_dialog (_frame, std_to_wx (m)); } - DOMFrame* _frame; + DOMFrame* _frame = nullptr; + wxSplashScreen* _splash = nullptr; }; IMPLEMENT_APP (App) diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 72ac93cc7..ab8a257f6 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -1066,7 +1066,6 @@ class App : public wxApp public: App () : wxApp () - , _frame (0) { #ifdef DCPOMATIC_LINUX XInitThreads (); @@ -1077,14 +1076,13 @@ private: bool OnInit () { - wxSplashScreen* splash = 0; try { wxInitAllImageHandlers (); Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this)); Config::Warning.connect (boost::bind (&App::config_warning, this, _1)); - splash = maybe_show_splash (); + _splash = maybe_show_splash (); SetAppName (_("DCP-o-matic Player")); @@ -1125,10 +1123,7 @@ private: _frame = new DOMFrame (); SetTopWindow (_frame); _frame->Maximize (); - if (splash) { - splash->Destroy (); - splash = 0; - } + close_splash (); _frame->Show (); PlayServer* server = new PlayServer (_frame); @@ -1158,9 +1153,7 @@ private: } catch (exception& e) { - if (splash) { - splash->Destroy (); - } + close_splash (); error_dialog (0, _("DCP-o-matic Player could not start."), std_to_wx(e.what())); } @@ -1235,17 +1228,28 @@ private: signal_manager->ui_idle (); } + void close_splash () + { + if (_splash) { + _splash->Destroy (); + _splash = nullptr; + } + } + void config_failed_to_load () { + close_splash (); message_dialog (_frame, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create.")); } void config_warning (string m) { + close_splash (); message_dialog (_frame, std_to_wx (m)); } - DOMFrame* _frame; + DOMFrame* _frame = nullptr; + wxSplashScreen* _splash = nullptr; string _dcp_to_load; boost::optional<string> _stress; }; diff --git a/src/tools/dcpomatic_server.cc b/src/tools/dcpomatic_server.cc index 4039a07ed..185788b98 100644 --- a/src/tools/dcpomatic_server.cc +++ b/src/tools/dcpomatic_server.cc @@ -255,12 +255,6 @@ private: class App : public wxApp, public ExceptionStore { -public: - App () - : wxApp () - , _icon (0) - {} - private: bool OnInit () @@ -278,7 +272,7 @@ private: Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this)); Config::Warning.connect (boost::bind (&App::config_warning, this, _1)); - wxSplashScreen* splash = maybe_show_splash (); + _splash = maybe_show_splash (); dcpomatic_setup_path_encoding (); dcpomatic_setup_i18n (); @@ -307,9 +301,7 @@ private: _timer.reset (new wxTimer (this)); _timer->Start (1000); - if (splash) { - splash->Destroy (); - } + close_splash (); SetExitOnFrameDelete (false); @@ -348,19 +340,30 @@ private: signal_manager->ui_idle (); } + void close_splash () + { + if (_splash) { + _splash->Destroy (); + _splash = 0; + } + } + void config_failed_to_load () { + close_splash (); message_dialog (0, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create.")); } void config_warning (string m) { + close_splash (); message_dialog (0, std_to_wx (m)); } boost::thread _thread; - TaskBarIcon* _icon; + TaskBarIcon* _icon = nullptr; shared_ptr<wxTimer> _timer; + wxSplashScreen* _splash = nullptr; }; IMPLEMENT_APP (App) |
