typeid() doesn't seem to downcast, so just check types in the take_settings_from...
authorCarl Hetherington <cth@carlh.net>
Thu, 8 Feb 2018 20:57:03 +0000 (20:57 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 8 Feb 2018 20:57:03 +0000 (20:57 +0000)
ChangeLog
src/lib/content.cc
src/lib/dcp_content.cc
src/lib/ffmpeg_content.cc
src/lib/film.cc

index 91263bed6d62d26dad20640d50a744ee1efd8e37..cd3e90e1dededa22bf10cb0742496f54f8252983 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2018-02-08  Carl Hetherington  <cth@carlh.net>
+
+       * Fix crash on adding content to a project created from a template
+       in some cases (#1192).
+
 2018-02-07  Carl Hetherington  <cth@carlh.net>
 
        * Version 2.11.50 released.
index 7b1e630a6610b92db3ec373b67f15d106db070a6..f2380653f661d54131e50194f42522742f07a562 100644 (file)
@@ -420,6 +420,7 @@ Content::add_properties (list<UserProperty>& p) const
        }
 }
 
+/** Take settings from the given content if it is of the correct type */
 void
 Content::take_settings_from (shared_ptr<const Content> c)
 {
index a6424874adb6978d488693c542fb4122d0206da6..ad489917d65c41e6a328ec6b0dd0f37b046085e9 100644 (file)
@@ -543,7 +543,9 @@ void
 DCPContent::take_settings_from (shared_ptr<const Content> c)
 {
        shared_ptr<const DCPContent> dc = dynamic_pointer_cast<const DCPContent> (c);
-       DCPOMATIC_ASSERT (dc);
+       if (!dc) {
+               return;
+       }
 
        _reference_video = dc->_reference_video;
        _reference_audio = dc->_reference_audio;
index 64da0b1af0b71d2f8e8d6909655a8ed08a896e41..06ed5a8014f81db7b29b3efe1bf73c1017a789b1 100644 (file)
@@ -606,8 +606,11 @@ FFmpegContent::ffmpeg_audio_streams () const
 void
 FFmpegContent::take_settings_from (shared_ptr<const Content> c)
 {
-       Content::take_settings_from (c);
-
        shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (c);
+       if (!fc) {
+               return;
+               }
+
+       Content::take_settings_from (c);
        _filters = fc->_filters;
 }
index 2b045f5c4c2fcef84503e4dc32874501deb94420..db1cb39aaad5b90075b6aaaca5eb67c118bf852f 100644 (file)
@@ -1086,9 +1086,7 @@ Film::add_content (shared_ptr<Content> c)
        if (_template_film) {
                /* Take settings from the first piece of content of c's type in _template */
                BOOST_FOREACH (shared_ptr<Content> i, _template_film->content()) {
-                       if (typeid(i.get()) == typeid(c.get())) {
-                               c->take_settings_from (i);
-                       }
+                       c->take_settings_from (i);
                }
        }