From e749511fb4839feaccc94d506fa13b89ab13a570 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 25 Oct 2014 23:52:42 +0100 Subject: [PATCH] Fix crash when signalling VideoContent during the constructor (hence indirectly causing shared_from_this to be called too early). --- src/lib/video_content.cc | 17 ++++++++++++----- src/lib/video_content.h | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 976bc3aa0..98c3d929a 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -65,7 +65,7 @@ VideoContent::VideoContent (shared_ptr f) , _video_frame_type (VIDEO_FRAME_TYPE_2D) , _scale (Config::instance()->default_scale ()) { - set_default_colour_conversion (); + set_default_colour_conversion (false); } VideoContent::VideoContent (shared_ptr f, DCPTime s, ContentTime len) @@ -75,7 +75,7 @@ VideoContent::VideoContent (shared_ptr f, DCPTime s, ContentTime len , _video_frame_type (VIDEO_FRAME_TYPE_2D) , _scale (Config::instance()->default_scale ()) { - set_default_colour_conversion (); + set_default_colour_conversion (false); } VideoContent::VideoContent (shared_ptr f, boost::filesystem::path p) @@ -85,7 +85,7 @@ VideoContent::VideoContent (shared_ptr f, boost::filesystem::path p) , _video_frame_type (VIDEO_FRAME_TYPE_2D) , _scale (Config::instance()->default_scale ()) { - set_default_colour_conversion (); + set_default_colour_conversion (false); } VideoContent::VideoContent (shared_ptr f, cxml::ConstNodePtr node, int version) @@ -197,9 +197,16 @@ VideoContent::as_xml (xmlpp::Node* node) const } void -VideoContent::set_default_colour_conversion () +VideoContent::set_default_colour_conversion (bool signal) { - set_colour_conversion (PresetColourConversion (_("sRGB"), 2.4, true, dcp::colour_matrix::srgb_to_xyz, 2.6).conversion); + { + boost::mutex::scoped_lock lm (_mutex); + _colour_conversion = PresetColourConversion (_("sRGB"), 2.4, true, dcp::colour_matrix::srgb_to_xyz, 2.6).conversion; + } + + if (signal) { + signal_changed (VideoContentProperty::COLOUR_CONVERSION); + } } void diff --git a/src/lib/video_content.h b/src/lib/video_content.h index 3c8e5fefd..b5936d16d 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -91,7 +91,7 @@ public: void set_scale (VideoContentScale); void unset_colour_conversion (); void set_colour_conversion (ColourConversion); - void set_default_colour_conversion (); + void set_default_colour_conversion (bool signal = true); void set_fade_in (ContentTime); void set_fade_out (ContentTime); -- 2.30.2