Remove Film pointer from clone().
authorCarl Hetherington <cth@carlh.net>
Wed, 21 Nov 2018 22:25:43 +0000 (22:25 +0000)
committerCarl Hetherington <cth@carlh.net>
Wed, 21 Nov 2018 22:25:43 +0000 (22:25 +0000)
src/lib/content.cc
src/lib/content.h
src/lib/content_factory.cc
src/lib/content_factory.h
src/lib/playlist.cc
src/tools/dcpomatic.cc
src/wx/controls.cc

index 5139eb4cc57557a828dc14f58da879baa573cec4..11bf63f11eb1c8e0761bd8d9491ab2076e61ff2c 100644 (file)
@@ -270,7 +270,7 @@ Content::set_trim_end (ContentTime t)
 
 
 shared_ptr<Content>
-Content::clone (shared_ptr<const Film> film) const
+Content::clone () const
 {
        /* This is a bit naughty, but I can't think of a compelling reason not to do it ... */
        xmlpp::Document doc;
@@ -279,7 +279,7 @@ Content::clone (shared_ptr<const Film> film) const
 
        /* notes is unused here (we assume) */
        list<string> notes;
-       return content_factory (film, cxml::NodePtr(new cxml::Node(node)), Film::current_state_version, notes);
+       return content_factory (cxml::NodePtr(new cxml::Node(node)), Film::current_state_version, notes);
 }
 
 string
index c6fa2c9f4ea315dc47e18a3b5b7653f463d021c7..47f29cb79e3f7626875e7546c628dfef1a375602 100644 (file)
@@ -97,7 +97,7 @@ public:
         */
        virtual std::list<DCPTime> reel_split_points () const;
 
-       boost::shared_ptr<Content> clone (boost::shared_ptr<const Film> film) const;
+       boost::shared_ptr<Content> clone () const;
 
        void set_paths (std::vector<boost::filesystem::path> paths);
 
index 934677c664dd99e3e14917109b89f36d7f089d53..30f02546cfa757c36854de594a4ea5bad52da430 100644 (file)
@@ -56,7 +56,7 @@ using boost::optional;
  *  @return Content object, or 0 if no content was recognised in the XML.
  */
 shared_ptr<Content>
-content_factory (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version, list<string>& notes)
+content_factory (cxml::ConstNodePtr node, int version, list<string>& notes)
 {
        string const type = node->string_child ("Type");
 
@@ -98,46 +98,6 @@ content_factory (shared_ptr<const Film> film, cxml::ConstNodePtr node, int versi
                content.reset (new AtmosMXFContent (node, version));
        }
 
-       /* See if this content should be nudged to start on a video frame */
-       DCPTime const old_pos = content->position();
-       content->set_position(film, old_pos);
-       if (old_pos != content->position()) {
-               string note = _("Your project contains video content that was not aligned to a frame boundary.");
-               note += "  ";
-               if (old_pos < content->position()) {
-                       note += String::compose(
-                               _("The file %1 has been moved %2 milliseconds later."),
-                               content->path_summary(), DCPTime(content->position() - old_pos).seconds() * 1000
-                               );
-               } else {
-                       note += String::compose(
-                               _("The file %1 has been moved %2 milliseconds earlier."),
-                               content->path_summary(), DCPTime(content->position() - old_pos).seconds() * 1000
-                               );
-               }
-               notes.push_back (note);
-       }
-
-       /* ...or have a start trim which is an integer number of frames */
-       ContentTime const old_trim = content->trim_start();
-       content->set_trim_start(old_trim);
-       if (old_trim != content->trim_start()) {
-               string note = _("Your project contains video content whose trim was not aligned to a frame boundary.");
-               note += "  ";
-               if (old_trim < content->trim_start()) {
-                       note += String::compose(
-                               _("The file %1 has been trimmed by %2 milliseconds more."),
-                               content->path_summary(), ContentTime(content->trim_start() - old_trim).seconds() * 1000
-                               );
-               } else {
-                       note += String::compose(
-                               _("The file %1 has been trimmed by %2 milliseconds less."),
-                               content->path_summary(), ContentTime(old_trim - content->trim_start()).seconds() * 1000
-                               );
-               }
-               notes.push_back (note);
-       }
-
        return content;
 }
 
index af77d93581e67a936982c286bd8d505e0ab5a508..2522ad01798c19f63b4fb52b6afc6f4d4733d582 100644 (file)
@@ -28,5 +28,5 @@
 class Film;
 class Content;
 
-extern boost::shared_ptr<Content> content_factory (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int, std::list<std::string> &);
+extern boost::shared_ptr<Content> content_factory (cxml::ConstNodePtr, int, std::list<std::string> &);
 extern std::list<boost::shared_ptr<Content> > content_factory (boost::filesystem::path);
index 0e6497495802a51b8338e46e628243ce798abb5b..c10235f9beb4e91a03d7cfc7adca9d4025dddf78 100644 (file)
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "util.h"
 #include "digester.h"
+#include "compose.hpp"
 #include <libcxml/cxml.h>
 #include <libxml++/libxml++.h>
 #include <boost/shared_ptr.hpp>
@@ -185,7 +186,49 @@ void
 Playlist::set_from_xml (shared_ptr<const Film> film, cxml::ConstNodePtr node, int version, list<string>& notes)
 {
        BOOST_FOREACH (cxml::NodePtr i, node->node_children ("Content")) {
-               _content.push_back (content_factory (film, i, version, notes));
+               shared_ptr<Content> content = content_factory (i, version, notes);
+
+               /* See if this content should be nudged to start on a video frame */
+               DCPTime const old_pos = content->position();
+               content->set_position(film, old_pos);
+               if (old_pos != content->position()) {
+                       string note = _("Your project contains video content that was not aligned to a frame boundary.");
+                       note += "  ";
+                       if (old_pos < content->position()) {
+                               note += String::compose(
+                                       _("The file %1 has been moved %2 milliseconds later."),
+                                       content->path_summary(), DCPTime(content->position() - old_pos).seconds() * 1000
+                                       );
+                       } else {
+                               note += String::compose(
+                                       _("The file %1 has been moved %2 milliseconds earlier."),
+                                       content->path_summary(), DCPTime(content->position() - old_pos).seconds() * 1000
+                                       );
+                       }
+                       notes.push_back (note);
+               }
+
+               /* ...or have a start trim which is an integer number of frames */
+               ContentTime const old_trim = content->trim_start();
+               content->set_trim_start(old_trim);
+               if (old_trim != content->trim_start()) {
+                       string note = _("Your project contains video content whose trim was not aligned to a frame boundary.");
+                       note += "  ";
+                       if (old_trim < content->trim_start()) {
+                               note += String::compose(
+                                       _("The file %1 has been trimmed by %2 milliseconds more."),
+                                       content->path_summary(), ContentTime(content->trim_start() - old_trim).seconds() * 1000
+                                       );
+                       } else {
+                               note += String::compose(
+                                       _("The file %1 has been trimmed by %2 milliseconds less."),
+                                       content->path_summary(), ContentTime(old_trim - content->trim_start()).seconds() * 1000
+                                       );
+                       }
+                       notes.push_back (note);
+               }
+
+               _content.push_back (content);
        }
 
        /* This shouldn't be necessary but better safe than sorry (there could be old files) */
@@ -470,7 +513,7 @@ Playlist::repeat (shared_ptr<const Film> film, ContentList c, int n)
        DCPTime pos = range.second;
        for (int i = 0; i < n; ++i) {
                BOOST_FOREACH (shared_ptr<Content> j, c) {
-                       shared_ptr<Content> copy = j->clone (film);
+                       shared_ptr<Content> copy = j->clone ();
                        copy->set_position (film, pos + copy->position() - range.first);
                        _content.push_back (copy);
                }
index 15c4363ee3587d0ef4ae96b9fe00ebe6ef346bd1..1a87a2872ee684269e727faf5c86a94db8ffe8e6 100644 (file)
@@ -595,7 +595,7 @@ private:
        {
                ContentList const sel = _film_editor->content_panel()->selected();
                DCPOMATIC_ASSERT (sel.size() == 1);
-               _clipboard = sel.front()->clone(_film);
+               _clipboard = sel.front()->clone();
        }
 
        void edit_paste ()
index af1dbdf14dd0db95ac8e7f2b5d137a690cca7a79..0fa92b69ada51014c1cca92e30ca7c25546be491 100644 (file)
@@ -214,7 +214,7 @@ Controls::Controls (wxWindow* parent, shared_ptr<FilmViewer> viewer, bool editor
 void
 Controls::add_clicked ()
 {
-       shared_ptr<Content> sel = selected_content()->clone(_film);
+       shared_ptr<Content> sel = selected_content()->clone();
        DCPOMATIC_ASSERT (sel);
        _film->examine_and_add_content (sel);
        bool const ok = display_progress (_("DCP-o-matic"), _("Loading DCP"));