diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-03-15 13:53:51 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-03-15 13:53:51 +0000 |
| commit | 5d3ebbb2e7844485e8dddd6471209d56b05633ae (patch) | |
| tree | ab1190b8789ebda46be3f2fdde05ce3332241940 /src | |
| parent | 16e8c1c7222796246f74153bf294909c3efe57dc (diff) | |
Cope with loading films with now-disabled filters.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/content.cc | 5 | ||||
| -rw-r--r-- | src/lib/content_factory.cc | 5 | ||||
| -rw-r--r-- | src/lib/content_factory.h | 2 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 9 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.h | 2 | ||||
| -rw-r--r-- | src/lib/film.cc | 12 | ||||
| -rw-r--r-- | src/lib/film.h | 2 | ||||
| -rw-r--r-- | src/lib/playlist.cc | 4 | ||||
| -rw-r--r-- | src/lib/playlist.h | 2 | ||||
| -rw-r--r-- | src/tools/dcpomatic.cc | 54 |
10 files changed, 60 insertions, 37 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc index 1883dfb4a..829468247 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -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 diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc index bab22b8eb..98b1dd859 100644 --- a/src/lib/content_factory.cc +++ b/src/lib/content_factory.cc @@ -24,17 +24,18 @@ #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") { diff --git a/src/lib/content_factory.h b/src/lib/content_factory.h index 071d925e0..2eeebbc9f 100644 --- a/src/lib/content_factory.h +++ b/src/lib/content_factory.h @@ -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); diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index e52e36f78..fadeec9cd 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -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"); diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index 9600666b3..6ab95d2fe 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -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 () { diff --git a/src/lib/film.cc b/src/lib/film.cc index 8aa0deed0..04692fc1e 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -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. diff --git a/src/lib/film.h b/src/lib/film.h index de9891c9f..162b67b35 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -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; diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index daa82cb94..608323e3b 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -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 ()); diff --git a/src/lib/playlist.h b/src/lib/playlist.h index 1915e3d04..394023f5c 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -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>); diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 6b534f4de..a36c4e240 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -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)); |
