Fix crash from previous commit; clear viewer image when its size changes (#12).
authorCarl Hetherington <cth@carlh.net>
Fri, 21 Dec 2012 23:09:59 +0000 (23:09 +0000)
committerCarl Hetherington <cth@carlh.net>
Fri, 21 Dec 2012 23:09:59 +0000 (23:09 +0000)
src/lib/util.cc
src/lib/util.h
src/wx/film_editor.cc
src/wx/film_viewer.cc
src/wx/film_viewer.h

index 66eaea39e21258328693570609926c475117cffb..a68496e94260bf90b5ab6bda607f709470d393a8 100644 (file)
@@ -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);
index 68c7bd3849a492b0b91f55b16a6d702e70229f6f..3832cc57945900b9ca82f61b5caee0501a510425 100644 (file)
@@ -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.
index 8cf8c5fda9e7ebf84a88d9ac0676d379a1f8bf77..22fd1cc1434bbbad958677ee67c60dbaa4b272d4 100644 (file)
@@ -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
index 3e0e678cf217ddf84d3e264462cd00913e1a41fc..73ed13e50aa0d9c7ba9281d636c85a4785822cb0 100644 (file)
@@ -55,6 +55,7 @@ FilmViewer::FilmViewer (shared_ptr<Film> 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,
index 77f014aab63fec10640968ff72f51c17632d6fcc..6029c04f32a7c02769f715248ae4a25bce774bb6 100644 (file)
@@ -77,4 +77,6 @@ private:
        int _out_height;
        int _panel_width;
        int _panel_height;
+
+       bool _clear_required;
 };