diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-07-19 13:54:18 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-07-19 13:54:18 +0100 |
| commit | 3857b8b178d94873a6ffc6f51cdb4c241fd54f90 (patch) | |
| tree | c321ebefb8ee1b6bd605969e6e1b2f01a2c59233 /src | |
| parent | a6d892268ccdf8e50194c0168491c8a360bbb687 (diff) | |
Fix unnecessary shared_ptr; add missing checked_set()s.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/timecode.cc | 8 | ||||
| -rw-r--r-- | src/wx/timeline.cc | 24 |
2 files changed, 15 insertions, 17 deletions
diff --git a/src/wx/timecode.cc b/src/wx/timecode.cc index 82c27c5b5..36a01f90d 100644 --- a/src/wx/timecode.cc +++ b/src/wx/timecode.cc @@ -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 diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index f9205fc5d..7d0ce660c 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -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; |
