From: Carl Hetherington Date: Thu, 8 Feb 2018 20:57:03 +0000 (+0000) Subject: typeid() doesn't seem to downcast, so just check types in the take_settings_from... X-Git-Tag: v2.11.51~1 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=d9825793692a41374b184f423994667b663d8526;hp=2a574403f57ff980ca5e627d389f30e91bff02c7 typeid() doesn't seem to downcast, so just check types in the take_settings_from methods (#1192). --- diff --git a/ChangeLog b/ChangeLog index 91263bed6..cd3e90e1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-02-08 Carl Hetherington + + * Fix crash on adding content to a project created from a template + in some cases (#1192). + 2018-02-07 Carl Hetherington * Version 2.11.50 released. diff --git a/src/lib/content.cc b/src/lib/content.cc index 7b1e630a6..f2380653f 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -420,6 +420,7 @@ Content::add_properties (list& p) const } } +/** Take settings from the given content if it is of the correct type */ void Content::take_settings_from (shared_ptr c) { diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index a6424874a..ad489917d 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -543,7 +543,9 @@ void DCPContent::take_settings_from (shared_ptr c) { shared_ptr dc = dynamic_pointer_cast (c); - DCPOMATIC_ASSERT (dc); + if (!dc) { + return; + } _reference_video = dc->_reference_video; _reference_audio = dc->_reference_audio; diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 64da0b1af..06ed5a801 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -606,8 +606,11 @@ FFmpegContent::ffmpeg_audio_streams () const void FFmpegContent::take_settings_from (shared_ptr c) { - Content::take_settings_from (c); - shared_ptr fc = dynamic_pointer_cast (c); + if (!fc) { + return; + } + + Content::take_settings_from (c); _filters = fc->_filters; } diff --git a/src/lib/film.cc b/src/lib/film.cc index 2b045f5c4..db1cb39aa 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1086,9 +1086,7 @@ Film::add_content (shared_ptr c) if (_template_film) { /* Take settings from the first piece of content of c's type in _template */ BOOST_FOREACH (shared_ptr i, _template_film->content()) { - if (typeid(i.get()) == typeid(c.get())) { - c->take_settings_from (i); - } + c->take_settings_from (i); } }