Be more careful to always close the splash screen when necessary.
authorCarl Hetherington <cth@carlh.net>
Tue, 23 Feb 2021 00:24:17 +0000 (01:24 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 23 Feb 2021 00:24:17 +0000 (01:24 +0100)
Trying to prevent error dialogues appearing behind it.

src/tools/dcpomatic.cc
src/tools/dcpomatic_batch.cc
src/tools/dcpomatic_kdm.cc
src/tools/dcpomatic_player.cc
src/tools/dcpomatic_server.cc

index be172ed2d0e29b5ec27af78a0f0630704d0eebc4..9b1280e3fe1f27f2bab4bbe0959895db21ac0b61 100644 (file)
@@ -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;
index 9cb6ddc5546fc3887a598641e9bfc5c0d3ddd996..73c9314112e51148e312277e5bf923bfafd1cabc 100644 (file)
@@ -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)
index ee5e454579bfda8812f6b2e324437dd5a4c59401..67c28da524e74dab5fb93fa9fb848e918da306db 100644 (file)
@@ -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)
index 72ac93cc75a48716782f2ef57c2df206607a17f5..ab8a257f6ea698138ce3d1b47277fb137310b019 100644 (file)
@@ -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;
 };
index 4039a07ed3702e67df0bc3370386b95a64fe6312..185788b987997720ab6ef7de5daaaccf6818fd17 100644 (file)
@@ -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)