From: Carl Hetherington Date: Wed, 28 Feb 2018 00:13:54 +0000 (+0000) Subject: Fix crash if quick_refresh() fails. X-Git-Tag: v2.13.0~32 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=3c88c626399fff9b95c89065d3b8ee9de1148d52 Fix crash if quick_refresh() fails. --- diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index c24f9ccaa..8eb39efed 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -286,17 +286,22 @@ PlayerVideo::shallow_copy () const ); } -/** Re-read crop, fade, inter/out size and colour conversion from our content */ -void +/** Re-read crop, fade, inter/out size and colour conversion from our content. + * @return true if this was possible, false if not. + */ +bool PlayerVideo::reset_metadata (dcp::Size video_container_size, dcp::Size film_frame_size) { shared_ptr content = _content.lock(); - DCPOMATIC_ASSERT (content); - DCPOMATIC_ASSERT (_video_frame); + if (!content || !_video_frame) { + return false; + } _crop = content->video->crop(); _fade = content->video->fade(_video_frame.get()); _inter_size = content->video->scale().size(content->video, video_container_size, film_frame_size); _out_size = video_container_size; _colour_conversion = content->video->colour_conversion(); + + return true; } diff --git a/src/lib/player_video.h b/src/lib/player_video.h index 7cc00f46b..f4bf2a471 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -71,7 +71,7 @@ public: void add_metadata (xmlpp::Node* node) const; void send_binary (boost::shared_ptr socket) const; - void reset_metadata (dcp::Size video_container_size, dcp::Size film_frame_size); + bool reset_metadata (dcp::Size video_container_size, dcp::Size film_frame_size); bool has_j2k () const; dcp::Data j2k () const; diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 11505e510..ade45d766 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -446,7 +446,9 @@ FilmViewer::panel_sized (wxSizeEvent& ev) _panel_size.height = ev.GetSize().GetHeight(); calculate_sizes (); - quick_refresh (); + if (!quick_refresh()) { + slow_refresh (); + } update_position_label (); update_position_slider (); } @@ -639,6 +641,7 @@ FilmViewer::player_changed (int property, bool frequent) } calculate_sizes (); + bool refreshed = false; if ( property == VideoContentProperty::CROP || property == VideoContentProperty::SCALE || @@ -648,8 +651,10 @@ FilmViewer::player_changed (int property, bool frequent) property == PlayerProperty::VIDEO_CONTAINER_SIZE || property == PlayerProperty::FILM_CONTAINER ) { - quick_refresh (); - } else { + refreshed = quick_refresh (); + } + + if (!refreshed) { slow_refresh (); } update_position_label (); @@ -696,16 +701,23 @@ FilmViewer::slow_refresh () seek (_video_position, true); } -/** Re-get the current frame quickly by resetting the metadata in the PlayerVideo that we used last time */ -void +/** Try to re-get the current frame quickly by resetting the metadata + * in the PlayerVideo that we used last time. + * @return true if this was possible, false if not. + */ +bool FilmViewer::quick_refresh () { if (!_player_video.first) { - return; + return false; + } + + if (!_player_video.first->reset_metadata (_player->video_container_size(), _film->frame_size())) { + return false; } - _player_video.first->reset_metadata (_player->video_container_size(), _film->frame_size()); display_player_video (); + return true; } void diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index f769fd6b9..a41cb310e 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -60,7 +60,7 @@ public: boost::optional dcp_decode_reduction () const; void slow_refresh (); - void quick_refresh (); + bool quick_refresh (); int dropped () const { return _dropped;