Try to improve error when failing to load config.
authorCarl Hetherington <cth@carlh.net>
Wed, 1 May 2019 23:28:07 +0000 (00:28 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 6 May 2019 20:31:09 +0000 (21:31 +0100)
src/lib/config.cc
src/lib/config.h
src/tools/dcpomatic.cc

index 74f916b21e49e52fa26ba224ccdb9b062e2f4059..b653c0118d95cdd6e2bd09bca5bab2337768abd8 100644 (file)
@@ -67,7 +67,7 @@ using dcp::raw_convert;
 
 Config* Config::_instance = 0;
 int const Config::_current_version = 3;
-boost::signals2::signal<void ()> Config::FailedToLoad;
+boost::signals2::signal<void (string)> Config::FailedToLoad;
 boost::signals2::signal<void (string)> Config::Warning;
 boost::signals2::signal<bool (Config::BadReason)> Config::Bad;
 
@@ -612,11 +612,24 @@ try
                read_cinemas (f);
        }
 }
+catch (exception& e) {
+       if (have_existing ("config.xml")) {
+               backup ();
+               /* We have a config file but it didn't load */
+               FailedToLoad (e.what());
+       }
+       set_defaults ();
+       /* Make a new set of signing certificates and key */
+       _signer_chain = create_certificate_chain ();
+       /* And similar for decryption of KDMs */
+       _decryption_chain = create_certificate_chain ();
+       write ();
+}
 catch (...) {
        if (have_existing ("config.xml")) {
                backup ();
                /* We have a config file but it didn't load */
-               FailedToLoad ();
+               FailedToLoad ("unknown");
        }
        set_defaults ();
        /* Make a new set of signing certificates and key */
index a8427663dd6c2fa4cd648842420437dfe365a617..0ba2180b1ee085a40c4d648db4d536e4d9bfd570 100644 (file)
@@ -1069,7 +1069,7 @@ public:
        /** Emitted if read() failed on an existing Config file.  There is nothing
            a listener can do about it: this is just for information.
        */
-       static boost::signals2::signal<void ()> FailedToLoad;
+       static boost::signals2::signal<void (std::string)> FailedToLoad;
        /** Emitted if read() issued a warning which the user might want to know about */
        static boost::signals2::signal<void (std::string)> Warning;
        /** Emitted if there is a something wrong the contents of our config.  Handler can call
index f6427e68ed5ca1fb30ff184690a2faff1f5efd3c..32fb6109884b73165a1ff1ee4ca668a4f6181af2 100644 (file)
@@ -1465,7 +1465,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 ();