From: Carl Hetherington Date: Fri, 21 Dec 2012 23:09:59 +0000 (+0000) Subject: Fix crash from previous commit; clear viewer image when its size changes (#12). X-Git-Tag: v2.0.48~1377 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=914a93ee4dd48583b057305f463bee3fb2254cc7;p=dcpomatic.git Fix crash from previous commit; clear viewer image when its size changes (#12). --- diff --git a/src/lib/util.cc b/src/lib/util.cc index 66eaea39e..a68496e94 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -369,6 +369,11 @@ bool operator== (Size const & a, Size const & b) return (a.width == b.width && a.height == b.height); } +bool operator!= (Size const & a, Size const & b) +{ + return !(a == b); +} + bool operator== (Crop const & a, Crop const & b) { return (a.left == b.left && a.right == b.right && a.top == b.top && a.bottom == b.bottom); diff --git a/src/lib/util.h b/src/lib/util.h index 68c7bd384..3832cc579 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -103,6 +103,7 @@ struct Size }; extern bool operator== (Size const & a, Size const & b); +extern bool operator!= (Size const & a, Size const & b); /** @struct Crop * @brief A description of the crop of an image or video. diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 8cf8c5fda..22fd1cc14 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -963,9 +963,15 @@ FilmEditor::setup_subtitle_control_sensitivity () } _with_subtitles->Enable (h); - _subtitle_stream->Enable (_film->with_subtitles ()); - _subtitle_offset->Enable (_film->with_subtitles ()); - _subtitle_scale->Enable (_film->with_subtitles ()); + + bool j = false; + if (_film) { + j = _film->with_subtitles (); + } + + _subtitle_stream->Enable (j); + _subtitle_offset->Enable (j); + _subtitle_scale->Enable (j); } void diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 3e0e678cf..73ed13e50 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -55,6 +55,7 @@ FilmViewer::FilmViewer (shared_ptr f, wxWindow* p) , _out_height (0) , _panel_width (0) , _panel_height (0) + , _clear_required (false) { _panel->SetDoubleBuffered (true); #if wxMAJOR_VERSION == 2 && wxMINOR_VERSION >= 9 @@ -189,6 +190,11 @@ FilmViewer::paint_panel (wxPaintEvent& ev) { wxPaintDC dc (_panel); + if (_clear_required) { + dc.Clear (); + _clear_required = false; + } + if (!_display_frame || !_film || !_out_width || !_out_height) { dc.Clear (); return; @@ -251,9 +257,18 @@ FilmViewer::raw_to_display () return; } + Size old_size; + if (_display_frame) { + old_size = _display_frame->size(); + } + /* Get a compacted image as we have to feed it to wxWidgets */ _display_frame = _raw_frame->scale_and_convert_to_rgb (Size (_out_width, _out_height), 0, _film->scaler(), false); + if (old_size != _display_frame->size()) { + _clear_required = true; + } + if (_raw_sub) { Rect tx = subtitle_transformed_area ( float (_out_width) / _film->size().width, diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 77f014aab..6029c04f3 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -77,4 +77,6 @@ private: int _out_height; int _panel_width; int _panel_height; + + bool _clear_required; };