Use raw_convert rather than lexical_cast.
[dcpomatic.git] / src / wx / gl_video_view.cc
index d47ad87f48cdfbe788bd9151d04920c7cd5bb0ac..0e4bcb671b88cfbebdba84ac0fe55a6b42169fe8 100644 (file)
@@ -57,7 +57,6 @@ GLVideoView::GLVideoView (FilmViewer* viewer, wxWindow *parent)
        : VideoView (viewer)
        , _have_storage (false)
        , _vsync_enabled (false)
-       , _thread (0)
        , _playing (false)
        , _one_shot (false)
 {
@@ -105,9 +104,12 @@ GLVideoView::GLVideoView (FilmViewer* viewer, wxWindow *parent)
 
 GLVideoView::~GLVideoView ()
 {
-       _thread->interrupt ();
-       _thread->join ();
-       delete _thread;
+       try {
+               _thread.interrupt ();
+               _thread.join ();
+       } catch (...) {
+
+       }
 
        glDeleteTextures (1, &_id);
 }
@@ -115,6 +117,10 @@ GLVideoView::~GLVideoView ()
 void
 GLVideoView::check_for_butler_errors ()
 {
+       if (!_viewer->butler()) {
+               return;
+       }
+
        try {
                _viewer->butler()->rethrow ();
        } catch (DecodeError& e) {
@@ -386,7 +392,7 @@ GLVideoView::request_one_shot ()
 void
 GLVideoView::create ()
 {
-       if (!_thread) {
-               _thread = new boost::thread (boost::bind(&GLVideoView::thread, this));
+       if (!_thread.joinable()) {
+               _thread = boost::thread (boost::bind(&GLVideoView::thread, this));
        }
 }