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 40f74fe..7b1e630 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 f0a2d0b..836a3bd 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 d7ed46f..653e446 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);