Cope with loading films with now-disabled filters.
authorCarl Hetherington <cth@carlh.net>
Sat, 15 Mar 2014 13:53:51 +0000 (13:53 +0000)
committerCarl Hetherington <cth@carlh.net>
Sat, 15 Mar 2014 13:53:51 +0000 (13:53 +0000)
src/lib/content.cc
src/lib/content_factory.cc
src/lib/content_factory.h
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_content.h
src/lib/film.cc
src/lib/film.h
src/lib/playlist.cc
src/lib/playlist.h
src/tools/dcpomatic.cc

index 1883dfb4a9276d7773a8fe8b3ba34f32ace08662..8294682475a65b30ceb6717f5eea37b1dff33fba 100644 (file)
@@ -195,7 +195,10 @@ Content::clone () const
        xmlpp::Document doc;
        xmlpp::Node* node = doc.create_root_node ("Content");
        as_xml (node);
-       return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::current_state_version);
+
+       /* notes is unused here (we assume) */
+       list<string> notes;
+       return content_factory (film, cxml::NodePtr (new cxml::Node (node)), Film::current_state_version, notes);
 }
 
 string
index bab22b8eb19e14b6179fd27696710c6b630df70c..98b1dd859536643c83c524e3a22a4df45b039c8a 100644 (file)
 #include "util.h"
 
 using std::string;
+using std::list;
 using boost::shared_ptr;
 
 shared_ptr<Content>
-content_factory (shared_ptr<const Film> film, cxml::NodePtr node, int version)
+content_factory (shared_ptr<const Film> film, cxml::NodePtr node, int version, list<string>& notes)
 {
        string const type = node->string_child ("Type");
 
        boost::shared_ptr<Content> content;
        
        if (type == "FFmpeg") {
-               content.reset (new FFmpegContent (film, node, version));
+               content.reset (new FFmpegContent (film, node, version, notes));
        } else if (type == "Image") {
                content.reset (new ImageContent (film, node, version));
        } else if (type == "Sndfile") {
index 071d925e034bbc19309671ede4c07dcd8014dcf0..2eeebbc9f8924c9ebb45c04df47bfdbefa9de22c 100644 (file)
@@ -19,5 +19,5 @@
 
 class Film;
 
-extern boost::shared_ptr<Content> content_factory (boost::shared_ptr<const Film>, cxml::NodePtr, int);
+extern boost::shared_ptr<Content> content_factory (boost::shared_ptr<const Film>, cxml::NodePtr, int, std::list<std::string> &);
 extern boost::shared_ptr<Content> content_factory (boost::shared_ptr<const Film>, boost::filesystem::path);
index e52e36f781e6663964e6208b145dcc0835040805..fadeec9cdc00a3126f2d9d066df8d04518229015 100644 (file)
@@ -58,7 +58,7 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> f, boost::filesystem::path
 
 }
 
-FFmpegContent::FFmpegContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node, int version)
+FFmpegContent::FFmpegContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node, int version, list<string>& notes)
        : Content (f, node)
        , VideoContent (f, node, version)
        , AudioContent (f, node)
@@ -82,7 +82,12 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> f, shared_ptr<const cxml::N
 
        c = node->node_children ("Filter");
        for (list<cxml::NodePtr>::iterator i = c.begin(); i != c.end(); ++i) {
-               _filters.push_back (Filter::from_id ((*i)->content ()));
+               Filter const * f = Filter::from_id ((*i)->content ());
+               if (f) {
+                       _filters.push_back (f);
+               } else {
+                       notes.push_back (String::compose (_("DCP-o-matic no longer supports the `%1' filter, so it has been turned off."), (*i)->content()));
+               }
        }
 
        _first_video = node->optional_number_child<double> ("FirstVideo");
index 9600666b3bf88aa48ae1e72724c4fdb6a6ef70fe..6ab95d2fe9d2bf53a08acd050845721ed40fc1a1 100644 (file)
@@ -127,7 +127,7 @@ class FFmpegContent : public VideoContent, public AudioContent, public SubtitleC
 {
 public:
        FFmpegContent (boost::shared_ptr<const Film>, boost::filesystem::path);
-       FFmpegContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>, int version);
+       FFmpegContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>, int version, std::list<std::string> &);
        FFmpegContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
 
        boost::shared_ptr<FFmpegContent> shared_from_this () {
index 8aa0deed0c5693cde69acfd25f57f797725feaf6..04692fc1ee5a7e2e2f7280d6fe9bd372a043e65a 100644 (file)
@@ -381,8 +381,10 @@ Film::write_metadata () const
        _dirty = false;
 }
 
-/** Read state from our metadata file */
-void
+/** Read state from our metadata file.
+ *  @return Notes about things that the user should know about, or empty.
+ */
+list<string>
 Film::read_metadata ()
 {
        LocaleGuard lg;
@@ -430,9 +432,13 @@ Film::read_metadata ()
        _three_d = f.bool_child ("ThreeD");
        _interop = f.bool_child ("Interop");
        _key = libdcp::Key (f.string_child ("Key"));
-       _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version);
+
+       list<string> notes;
+       /* This method is the only one that can return notes (so far) */
+       _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version, notes);
 
        _dirty = false;
+       return notes;
 }
 
 /** Given a directory name, return its full path within the Film's directory.
index de9891c9f33ea2a54d10b65d009572988cdb7d39..162b67b351bd6b9d0e2a97a6dc60e5b1e49387e1 100644 (file)
@@ -83,7 +83,7 @@ public:
        boost::filesystem::path file (boost::filesystem::path f) const;
        boost::filesystem::path dir (boost::filesystem::path d) const;
 
-       void read_metadata ();
+       std::list<std::string> read_metadata ();
        void write_metadata () const;
        boost::shared_ptr<xmlpp::Document> metadata () const;
 
index daa82cb94a56e305dc3420424f15e2d7a4f1cf41..608323e3b5bde2aa32c6fc074541f73ac10afcdc 100644 (file)
@@ -113,11 +113,11 @@ Playlist::video_identifier () const
 
 /** @param node <Playlist> node */
 void
-Playlist::set_from_xml (shared_ptr<const Film> film, shared_ptr<const cxml::Node> node, int version)
+Playlist::set_from_xml (shared_ptr<const Film> film, shared_ptr<const cxml::Node> node, int version, list<string>& notes)
 {
        list<cxml::NodePtr> c = node->node_children ("Content");
        for (list<cxml::NodePtr>::iterator i = c.begin(); i != c.end(); ++i) {
-               _content.push_back (content_factory (film, *i, version));
+               _content.push_back (content_factory (film, *i, version, notes));
        }
 
        sort (_content.begin(), _content.end(), ContentSorter ());
index 1915e3d045a01cabe7058c0fb4af089599548842..394023f5c5c90e4315b1fc9d4f37d8ef394a1f5e 100644 (file)
@@ -56,7 +56,7 @@ public:
        ~Playlist ();
 
        void as_xml (xmlpp::Node *);
-       void set_from_xml (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>, int);
+       void set_from_xml (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>, int, std::list<std::string> &);
 
        void add (boost::shared_ptr<Content>);
        void remove (boost::shared_ptr<Content>);
index 6b534f4dea4558fe9318eedc0f2f6519c50bddf8..a36c4e2409049630b5d061b3adeeb5afc8e50874 100644 (file)
@@ -114,7 +114,7 @@ private:
 };
 
 
-void
+static void
 maybe_save_then_delete_film ()
 {
        if (!film) {
@@ -135,6 +135,30 @@ maybe_save_then_delete_film ()
        film.reset ();
 }
 
+static void
+check_film_state_version (int v)
+{
+       if (v == 4) {
+               error_dialog (
+                       0,
+                       _("This film was created with an old version of DVD-o-matic and may not load correctly "
+                         "in this version.  Please check the film's settings carefully.")
+                       );
+       }
+}
+
+static void
+load_film (boost::filesystem::path file)
+{
+       film.reset (new Film (file));
+       list<string> const notes = film->read_metadata ();
+       check_film_state_version (film->state_version ());
+       for (list<string>::const_iterator i = notes.begin(); i != notes.end(); ++i) {
+               error_dialog (0, std_to_wx (*i));
+       }
+       film->log()->set_level (log_level);
+}
+
 #define ALWAYS                  0x0
 #define NEEDS_FILM              0x1
 #define NOT_DURING_DCP_CREATION 0x2
@@ -142,14 +166,14 @@ maybe_save_then_delete_film ()
 
 map<wxMenuItem*, int> menu_items;
        
-void
+static void
 add_item (wxMenu* menu, wxString text, int id, int sens)
 {
        wxMenuItem* item = menu->Append (id, text);
        menu_items.insert (make_pair (item, sens));
 }
 
-void
+static void
 set_menu_sensitivity ()
 {
        list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
@@ -194,7 +218,7 @@ enum {
        ID_tools_check_for_updates
 };
 
-void
+static void
 setup_menu (wxMenuBar* m)
 {
        wxMenu* file = new wxMenu;
@@ -326,17 +350,6 @@ public:
                overall_panel->SetSizer (main_sizer);
        }
 
-       void check_film_state_version (int v)
-       {
-               if (v == 4) {
-                       error_dialog (
-                               this,
-                               _("This film was created with an old version of DVD-o-matic and may not load correctly "
-                                 "in this version.  Please check the film's settings carefully.")
-                               );
-               }
-       }
-
 private:
 
        void set_film ()
@@ -416,10 +429,7 @@ private:
                if (r == wxID_OK) {
                        maybe_save_then_delete_film ();
                        try {
-                               film.reset (new Film (wx_to_std (c->GetPath ())));
-                               film->read_metadata ();
-                               check_film_state_version (film->state_version ());
-                               film->log()->set_level (log_level);
+                               load_film (wx_to_std (c->GetPath ()));
                                set_film ();
                        } catch (std::exception& e) {
                                wxString p = c->GetPath ();
@@ -645,9 +655,7 @@ class App : public wxApp
 
                if (!film_to_load.empty() && boost::filesystem::is_directory (film_to_load)) {
                        try {
-                               film.reset (new Film (film_to_load));
-                               film->read_metadata ();
-                               film->log()->set_level (log_level);
+                               load_film (film_to_load);
                        } catch (exception& e) {
                                error_dialog (0, std_to_wx (String::compose (wx_to_std (_("Could not load film %1 (%2)")), film_to_load, e.what())));
                        }
@@ -677,7 +685,7 @@ class App : public wxApp
                _timer->Start (1000);
 
                if (film) {
-                       _frame->check_film_state_version (film->state_version ());
+                       check_film_state_version (film->state_version ());
                }
 
                UpdateChecker::instance()->StateChanged.connect (boost::bind (&App::update_checker_state_changed, this));