Don't try opening error dialogues from the GL thread.
authorCarl Hetherington <cth@carlh.net>
Wed, 20 Nov 2019 21:18:33 +0000 (22:18 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 8 Jan 2020 20:56:47 +0000 (21:56 +0100)
src/wx/gl_video_view.cc
src/wx/gl_video_view.h
src/wx/simple_video_view.cc
src/wx/video_view.cc

index a1be8ca301816f77e5b3e52017e0452d4a70d0de..836b3eb351584b790e9c6f077c4e090b3d73277a 100644 (file)
 
 #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 <boost/bind.hpp>
 #include <iostream>
 
@@ -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)
 {
index a9264f05dd6d0cdaa8b3e049a84b24b371e894e0..614393024bfc825231990351d8d589be49ca2cfb 100644 (file)
@@ -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<wxTimer> _timer;
 };
index 7aeb317b281a4fb6811f45fa70db0de6989d182c..f928770ad38bb56e534e3c23041de8ace20d4075 100644 (file)
@@ -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;
 }
 
index f8d44dc70137f321aec43a5610577032417ca1dc..ede0708c220a6eecb434df4bfd9a3a36978863f4 100644 (file)
@@ -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;
 }