Tidy up code to report failures to load config in the UI.
authorCarl Hetherington <cth@carlh.net>
Sun, 4 Sep 2022 19:26:03 +0000 (21:26 +0200)
committerCarl Hetherington <cth@carlh.net>
Mon, 5 Sep 2022 21:52:03 +0000 (23:52 +0200)
src/tools/dcpomatic.cc
src/tools/dcpomatic_batch.cc
src/tools/dcpomatic_combiner.cc
src/tools/dcpomatic_kdm.cc
src/tools/dcpomatic_server.cc
src/wx/wx_util.cc
src/wx/wx_util.h

index 57fad5a0a49ac031ca42365feebe956fdad23493..772d90050687f3daa5b0c9e97c6f2845afd5fcd8 100644 (file)
@@ -1606,7 +1606,7 @@ private:
                try {
                        wxInitAllImageHandlers ();
 
-                       Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
+                       Config::FailedToLoad.connect(boost::bind(&App::config_failed_to_load, this, _1));
                        Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
 
                        _splash = maybe_show_splash ();
@@ -1828,9 +1828,9 @@ private:
                }
        }
 
-       void config_failed_to_load ()
+       void config_failed_to_load (Config::LoadFailure what)
        {
-               message_dialog (_frame, _("The existing configuration failed to load.  Default values will be used instead.  These may take a short time to create."));
+               report_config_load_failure(_frame, what);
        }
 
        void config_warning (string m)
index 79f1b39fa0f7080efda7cef3c9759bb5f37410dd..dcda39fd8042c336a3302f293dcd5c21e69ea5e5 100644 (file)
@@ -401,7 +401,7 @@ class App : public wxApp
                SetAppName (_("DCP-o-matic Batch Converter"));
                is_batch_converter = true;
 
-               Config::FailedToLoad.connect (boost::bind(&App::config_failed_to_load, this));
+               Config::FailedToLoad.connect(boost::bind(&App::config_failed_to_load, this, _1));
                Config::Warning.connect (boost::bind(&App::config_warning, this, _1));
 
                auto splash = maybe_show_splash ();
@@ -488,9 +488,9 @@ class App : public wxApp
                return true;
        }
 
-       void config_failed_to_load ()
+       void config_failed_to_load(Config::LoadFailure what)
        {
-               message_dialog (_frame, _("The existing configuration failed to load.  Default values will be used instead.  These may take a short time to create."));
+               report_config_load_failure(_frame, what);
        }
 
        void config_warning (string m)
index 2ef58bb85011fe59bfffd8491d78eb875a50a65c..e773e4a37e3bfcaef0dc77df8592e36fb8bd922b 100644 (file)
@@ -210,7 +210,7 @@ public:
        bool OnInit () override
        {
                try {
-                       Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
+                       Config::FailedToLoad.connect(boost::bind(&App::config_failed_to_load, this, _1));
                        Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
 
                        SetAppName (_("DCP-o-matic Combiner"));
@@ -264,9 +264,9 @@ public:
                return true;
        }
 
-       void config_failed_to_load ()
+       void config_failed_to_load(Config::LoadFailure what)
        {
-               message_dialog (_frame, _("The existing configuration failed to load.  Default values will be used instead.  These may take a short time to create."));
+               report_config_load_failure(_frame, what);
        }
 
        void config_warning (string m)
index 62955142a7aaf4dd073d77d51c910cffd67bc0b9..f877ad21f8510d4848f4f162660e563440aca29b 100644 (file)
@@ -645,7 +645,7 @@ private:
                try {
                        wxInitAllImageHandlers ();
 
-                       Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
+                       Config::FailedToLoad.connect(boost::bind(&App::config_failed_to_load, this, _1));
                        Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
 
                        splash = maybe_show_splash ();
@@ -747,9 +747,9 @@ private:
                signal_manager->ui_idle ();
        }
 
-       void config_failed_to_load ()
+       void config_failed_to_load(Config::LoadFailure what)
        {
-               message_dialog (_frame, _("The existing configuration failed to load.  Default values will be used instead.  These may take a short time to create."));
+               report_config_load_failure(_frame, what);
        }
 
        void config_warning (string m)
index fe70ec6f716dade9aaa3f19b4cce98baea2101e6..e5e3a7e5a072e6a5838f8ff40e149cd49e3bae51 100644 (file)
@@ -287,7 +287,7 @@ private:
                server_log->set_types (LogEntry::TYPE_GENERAL | LogEntry::TYPE_WARNING | LogEntry::TYPE_ERROR);
                dcpomatic_log = server_log;
 
-               Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
+               Config::FailedToLoad.connect(boost::bind(&App::config_failed_to_load, this, _1));
                Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
 
                auto splash = maybe_show_splash ();
@@ -361,9 +361,9 @@ private:
                signal_manager->ui_idle ();
        }
 
-       void config_failed_to_load ()
+       void config_failed_to_load(Config::LoadFailure what)
        {
-               message_dialog (nullptr, _("The existing configuration failed to load.  Default values will be used instead.  These may take a short time to create."));
+               report_config_load_failure(nullptr, what);
        }
 
        void config_warning (string m)
index e94f3e512acf03322be4f09032a09d0147cceb1b..d02eb3ca5d3b3e68a6f5d26b87e1fd19ac14480d 100644 (file)
@@ -700,3 +700,27 @@ search_ctrl_height ()
 #endif
 }
 
+
+void
+report_config_load_failure(wxWindow* parent, Config::LoadFailure what)
+{
+       switch (what) {
+       case Config::LoadFailure::CONFIG:
+               message_dialog(parent, _("The existing configuration failed to load.  Default values will be used instead.  These may take a short time to create."));
+               break;
+       case Config::LoadFailure::CINEMAS:
+               message_dialog(
+                       parent,
+                       _(wxString::Format("The cinemas list for creating KDMs (cinemas.xml) failed to load.  Please check the numbered backup files in %s",
+                                          std_to_wx(Config::instance()->cinemas_file().parent_path().string())))
+                       );
+               break;
+       case Config::LoadFailure::DKDM_RECIPIENTS:
+               message_dialog(
+                       parent,
+                       _(wxString::Format("The recipients list for creating DKDMs (dkdm_recipients.xml) failed to load.  Please check the numbered backup files in %s",
+                                          std_to_wx(Config::instance()->dkdm_recipients_file().parent_path().string())))
+                       );
+               break;
+       }
+}
index 14f203688668a7aa2a424bf909f279e12884a5d9..fb1a3a001ecd6064467ea3bd97347ac435beb52b 100644 (file)
@@ -28,6 +28,7 @@
 #define DCPOMATIC_WX_UTIL_H
 
 
+#include "lib/config.h"
 #include "lib/dcpomatic_time.h"
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
@@ -122,7 +123,7 @@ extern wxSize small_button_size (wxWindow* parent, wxString text);
 extern bool gui_is_dark ();
 extern double dpi_scale_factor (wxWindow* window);
 extern int search_ctrl_height ();
-
+extern void report_config_load_failure(wxWindow* parent, Config::LoadFailure what);
 
 struct Offset
 {