Fix unnecessary shared_ptr; add missing checked_set()s.
authorCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 12:54:18 +0000 (13:54 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 12:54:18 +0000 (13:54 +0100)
src/wx/timecode.cc
src/wx/timeline.cc

index 82c27c5b5ad171a63b18297fd3308d374921e4fe..36a01f90d01eacda6c01c707abc8e6c4750d7e87 100644 (file)
@@ -84,10 +84,10 @@ Timecode::set (Time t, int fps)
        t -= s * TIME_HZ;
        int const f = t * fps / TIME_HZ;
 
-       _hours->SetValue (wxString::Format (wxT ("%d"), h));
-       _minutes->SetValue (wxString::Format (wxT ("%d"), m));
-       _seconds->SetValue (wxString::Format (wxT ("%d"), s));
-       _frames->SetValue (wxString::Format (wxT ("%d"), f));
+       checked_set (_hours, lexical_cast<string> (h));
+       checked_set (_minutes, lexical_cast<string> (m));
+       checked_set (_seconds, lexical_cast<string> (s));
+       checked_set (_frames, lexical_cast<string> (f));
 }
 
 Time
index f9205fc5d74264dc7315a7abd1b27b95b21ea2e2..7d0ce660c3e3f88437eb69b621ba992ba60c5738 100644 (file)
@@ -87,14 +87,15 @@ public:
        dcpomatic::Rect<int> bbox () const
        {
                shared_ptr<const Film> film = _timeline.film ();
-               if (!film) {
+               shared_ptr<const Content> content = _content.lock ();
+               if (!film || !content) {
                        return dcpomatic::Rect<int> ();
                }
                
                return dcpomatic::Rect<int> (
-                       time_x (_content->start ()) - 8,
+                       time_x (content->start ()) - 8,
                        y_pos (_track) - 8,
-                       _content->length () * _timeline.pixels_per_time_unit() + 16,
+                       content->length () * _timeline.pixels_per_time_unit() + 16,
                        _timeline.track_height() + 16
                        );
        }
@@ -109,7 +110,7 @@ public:
        }
 
        shared_ptr<Content> content () const {
-               return _content;
+               return _content.lock ();
        }
 
        void set_track (int t) {
@@ -128,12 +129,13 @@ private:
        void do_paint (wxGraphicsContext* gc)
        {
                shared_ptr<const Film> film = _timeline.film ();
-               if (!film) {
+               shared_ptr<const Content> cont = content ();
+               if (!film || !cont) {
                        return;
                }
 
-               Time const start = _content->start ();
-               Time const len = _content->length ();
+               Time const start = cont->start ();
+               Time const len = cont->length ();
 
                wxColour selected (colour().Red() / 2, colour().Green() / 2, colour().Blue() / 2);
 
@@ -155,7 +157,7 @@ private:
                gc->StrokePath (path);
                gc->FillPath (path);
 
-               wxString name = wxString::Format (wxT ("%s [%s]"), std_to_wx (_content->file().filename().string()).data(), type().data());
+               wxString name = wxString::Format (wxT ("%s [%s]"), std_to_wx (cont->file().filename().string()).data(), type().data());
                wxDouble name_width;
                wxDouble name_height;
                wxDouble name_descent;
@@ -179,11 +181,7 @@ private:
                }
        }
 
-       /* This must be a shared_ptr, not a weak_ptr, as in the looped case this
-          will be the only remaining pointer to the looped content that we get
-          from the playlist.
-       */
-       boost::shared_ptr<Content> _content;
+       boost::weak_ptr<Content> _content;
        int _track;
        bool _selected;