From 83c9e9c858072ab919916269790dcc65565fdd25 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 20 Nov 2019 22:18:33 +0100 Subject: [PATCH] Don't try opening error dialogues from the GL thread. --- src/wx/gl_video_view.cc | 16 ++++++++++++++++ src/wx/gl_video_view.h | 3 +++ src/wx/simple_video_view.cc | 6 ++++++ src/wx/video_view.cc | 7 ------- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/wx/gl_video_view.cc b/src/wx/gl_video_view.cc index a1be8ca30..836b3eb35 100644 --- a/src/wx/gl_video_view.cc +++ b/src/wx/gl_video_view.cc @@ -20,11 +20,13 @@ #include "gl_video_view.h" #include "film_viewer.h" +#include "wx_util.h" #include "lib/image.h" #include "lib/dcpomatic_assert.h" #include "lib/exceptions.h" #include "lib/cross.h" #include "lib/player_video.h" +#include "lib/butler.h" #include #include @@ -63,6 +65,10 @@ GLVideoView::GLVideoView (FilmViewer* viewer, wxWindow *parent) _canvas->Bind (wxEVT_SIZE, boost::bind(boost::ref(Sized))); _canvas->Bind (wxEVT_CREATE, boost::bind(&GLVideoView::create, this)); + _canvas->Bind (wxEVT_TIMER, boost::bind(&GLVideoView::check_for_butler_errors, this)); + _timer.reset (new wxTimer(_canvas)); + _timer->Start (2000); + #if defined(DCPOMATIC_LINUX) && defined(DCPOMATIC_HAVE_GLX_SWAP_INTERVAL_EXT) if (_canvas->IsExtensionSupported("GLX_EXT_swap_control")) { /* Enable vsync */ @@ -105,6 +111,16 @@ GLVideoView::~GLVideoView () glDeleteTextures (1, &_id); } +void +GLVideoView::check_for_butler_errors () +{ + try { + _viewer->butler()->rethrow (); + } catch (DecodeError& e) { + error_dialog (get(), e.what()); + } +} + static void check_gl_error (char const * last) { diff --git a/src/wx/gl_video_view.h b/src/wx/gl_video_view.h index a9264f05d..614393024 100644 --- a/src/wx/gl_video_view.h +++ b/src/wx/gl_video_view.h @@ -55,6 +55,7 @@ private: void thread (); void request_one_shot (); void create (); + void check_for_butler_errors (); wxGLCanvas* _canvas; wxGLContext* _context; @@ -68,4 +69,6 @@ private: boost::condition _playing_condition; bool _playing; bool _one_shot; + + boost::shared_ptr _timer; }; diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc index 7aeb317b2..f928770ad 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -194,6 +194,12 @@ SimpleVideoView::display_next_frame (bool non_blocking) display_player_video (); + try { + _viewer->butler()->rethrow (); + } catch (DecodeError& e) { + error_dialog (get(), e.what()); + } + return true; } diff --git a/src/wx/video_view.cc b/src/wx/video_view.cc index f8d44dc70..ede0708c2 100644 --- a/src/wx/video_view.cc +++ b/src/wx/video_view.cc @@ -59,13 +59,6 @@ VideoView::get_next_frame (bool non_blocking) _player_video.first->eyes() != EYES_BOTH ); - /* XXX_b: this is called from the GL thread so it shouldn't be opening error dialogs */ - try { - _viewer->butler()->rethrow (); - } catch (DecodeError& e) { - error_dialog (get(), e.what()); - } - return true; } -- 2.30.2