Cope nicely if the user has a configured default container ratio which is now disallowed.
authorCarl Hetherington <cth@carlh.net>
Sat, 19 Aug 2017 22:57:24 +0000 (23:57 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 19 Aug 2017 22:57:24 +0000 (23:57 +0100)
ChangeLog
src/lib/config.cc
src/lib/config.h
src/lib/ratio.h
src/tools/dcpomatic.cc

index fa717f3b084a73fc91d57a800ae35c78c4af14ef..2ebc966a2d541ee881fd15f9173106e5c090f556 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-19  Carl Hetherington  <cth@carlh.net>
+
+       * Deal with newly-invalid configured default container ratios
+       gracefully.
+
 2017-08-18  Carl Hetherington  <cth@carlh.net>
 
        * Version 2.11.18 released.
index f7456e2699ea9af7944586cb772542e024372c58..f595b960a888556926a3de3d3bc8081296538e62 100644 (file)
@@ -64,6 +64,7 @@ using dcp::raw_convert;
 
 Config* Config::_instance = 0;
 boost::signals2::signal<void ()> Config::FailedToLoad;
+boost::signals2::signal<void (string)> Config::Warning;
 
 /** Construct default configuration */
 Config::Config ()
@@ -225,6 +226,11 @@ try
                _default_container = Ratio::from_id (c.get ());
        }
 
+       if (_default_container && !_default_container->used_for_container()) {
+               Warning (_("Your default container is not valid and has been changed to Flat (1.85:1)"));
+               _default_container = Ratio::from_id ("185");
+       }
+
        c = f.optional_string_child ("DefaultScaleTo");
        if (c) {
                _default_scale_to = Ratio::from_id (c.get ());
@@ -475,9 +481,9 @@ Config::write_config () const
                root->add_child("Language")->add_child_text (_language.get());
        }
        if (_default_container) {
-               /* [XML:opt] DefaultContainer ID of default container to use when creating new films (<code>119</code>, <code>133</code>,
-                  <code>138</code>, <code>143</code>, <code>166</code>, <code>178</code>, <code>185</code>, <code>235</code>,
-                  <code>239</code> or <code>full-frame</code>).
+               /* [XML:opt] DefaultContainer ID of default container
+                * to use when creating new films (<code>185</code>,<code>239</code> or
+                * <code>full-frame</code>).
                */
                root->add_child("DefaultContainer")->add_child_text (_default_container->id ());
        }
index b850e99a784f6483912a2e1b890b65c16830ea90..0a81dee5132679e9d461d8c8e5b4a4b3510ea6e0 100644 (file)
@@ -625,6 +625,8 @@ public:
            a listener can do about it: this is just for information.
        */
        static boost::signals2::signal<void ()> FailedToLoad;
+       /** Emitted if read() issued a warning which the user might want to know about */
+       static boost::signals2::signal<void (std::string)> Warning;
 
        void write () const;
        void write_config () const;
index 42f29458ab883deead8b9ea4f826d3eefa6da5d1..a6f2bbd739e048190a642c7796d4114777e84c0f 100644 (file)
@@ -46,6 +46,10 @@ public:
 
        std::string container_nickname () const;
 
+       bool used_for_container () const {
+               return static_cast<bool> (_container_nickname);
+       }
+
        std::string isdcf_name () const {
                return _isdcf_name;
        }
index 0da3faa5bcd0e32054ecddb44a236368810884b3..f90f27c305d7101b79cdc6e907b1f67de8e846d2 100644 (file)
@@ -1166,6 +1166,7 @@ private:
                wxInitAllImageHandlers ();
 
                Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
+               Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
 
                wxSplashScreen* splash = 0;
                try {
@@ -1351,6 +1352,11 @@ private:
                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)
+       {
+               message_dialog (_frame, std_to_wx (m));
+       }
+
        DOMFrame* _frame;
        shared_ptr<wxTimer> _timer;
        string _film_to_load;