Give a better error when opening a DCP with File -> Open by mistake (#1723).
[dcpomatic.git] / src / lib / film.cc
index f7fd96a01a35e4f405bb0f575ec9cb161092de03..691ef58dab1012f0b2dfb8c96d7b141e7b34ffc2 100644 (file)
@@ -167,8 +167,9 @@ Film::Film (optional<boost::filesystem::path> dir)
        set_isdcf_date_today ();
 
        _playlist_change_connection = _playlist->Change.connect (bind (&Film::playlist_change, this, _1));
-       _playlist_order_changed_connection = _playlist->OrderChanged.connect (bind (&Film::playlist_order_changed, this));
+       _playlist_order_changed_connection = _playlist->OrderChange.connect (bind (&Film::playlist_order_changed, this));
        _playlist_content_change_connection = _playlist->ContentChange.connect (bind (&Film::playlist_content_change, this, _1, _2, _3, _4));
+       _playlist_length_change_connection = _playlist->LengthChange.connect (bind(&Film::playlist_length_change, this));
 
        if (dir) {
                /* Make state.directory a complete path without ..s (where possible)
@@ -427,6 +428,7 @@ Film::metadata (bool with_content_paths) const
        BOOST_FOREACH (dcp::Rating i, _ratings) {
                i.as_xml (root->add_child("Rating"));
        }
+       root->add_child("ContentVersion")->add_child_text(_content_version);
        _playlist->as_xml (root->add_child ("Playlist"), with_content_paths);
 
        return doc;
@@ -473,6 +475,10 @@ Film::read_metadata (optional<boost::filesystem::path> path)
                path = file (metadata_file);
        }
 
+       if (!boost::filesystem::exists(*path)) {
+               throw FileNotFoundError(*path);
+       }
+
        cxml::Document f ("Metadata");
        f.read_file (path.get ());
 
@@ -570,6 +576,8 @@ Film::read_metadata (optional<boost::filesystem::path> path)
                _ratings.push_back (dcp::Rating(i));
        }
 
+       _content_version = f.optional_string_child("ContentVersion").get_value_or("");
+
        list<string> notes;
        _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"), _state_version, notes);
 
@@ -1289,6 +1297,12 @@ Film::playlist_content_change (ChangeType type, weak_ptr<Content> c, int p, bool
        }
 }
 
+void
+Film::playlist_length_change ()
+{
+       LengthChange ();
+}
+
 void
 Film::playlist_change (ChangeType type)
 {
@@ -1763,6 +1777,13 @@ Film::set_ratings (vector<dcp::Rating> r)
        _ratings = r;
 }
 
+void
+Film::set_content_version (string v)
+{
+       ChangeSignaller<Film> ch (this, CONTENT_VERSION);
+       _content_version = v;
+}
+
 optional<DCPTime>
 Film::marker (dcp::Marker type) const
 {