Fix crash when unsetting forced video frame rates in the timing panel.
authorCarl Hetherington <cth@carlh.net>
Sat, 13 Jan 2018 22:49:51 +0000 (22:49 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 14 Jan 2018 00:24:46 +0000 (00:24 +0000)
src/lib/content.cc
src/lib/content.h
src/wx/timing_panel.cc

index 40f74fe9aae75866aa146286541e5847ca6dcaaf..7b1e630a6610b92db3ec373b67f15d106db070a6 100644 (file)
@@ -48,6 +48,7 @@ using std::vector;
 using std::max;
 using std::pair;
 using boost::shared_ptr;
+using boost::optional;
 using dcp::raw_convert;
 using dcp::locale_convert;
 
@@ -361,6 +362,17 @@ Content::set_video_frame_rate (double r)
        signal_changed (ContentProperty::VIDEO_FRAME_RATE);
 }
 
+void
+Content::unset_video_frame_rate ()
+{
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               _video_frame_rate = optional<double>();
+       }
+
+       signal_changed (ContentProperty::VIDEO_FRAME_RATE);
+}
+
 double
 Content::active_video_frame_rate () const
 {
index f0a2d0bdb1fe79ca05008b2eababe83e13ac69ee..836a3bd77e01c50d52a7233b38d1e147c7d49ad4 100644 (file)
@@ -166,6 +166,7 @@ public:
        }
 
        void set_video_frame_rate (double r);
+       void unset_video_frame_rate ();
 
        double active_video_frame_rate () const;
 
index d7ed46f467eca85192d6b6c355cf375830a72d9b..653e4466955e55e880683cb054ee2daaa84afad7 100644 (file)
@@ -409,9 +409,16 @@ TimingPanel::video_frame_rate_changed ()
 void
 TimingPanel::set_video_frame_rate ()
 {
-       double const fr = locale_convert<double> (wx_to_std (_video_frame_rate->GetValue ()));
+       optional<double> fr;
+       if (_video_frame_rate->GetValue() != wxT("")) {
+               fr = locale_convert<double> (wx_to_std (_video_frame_rate->GetValue ()));
+       }
        BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
-               i->set_video_frame_rate (fr);
+               if (fr) {
+                       i->set_video_frame_rate (*fr);
+               } else {
+                       i->unset_video_frame_rate ();
+               }
        }
 
        _set_video_frame_rate->Enable (false);