From 93aa8d3734d5165d87034cfae222e492f4f2e7ff Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 2 Sep 2015 14:28:26 +0200 Subject: [PATCH] waveform, mutex for _current_image may be used in render-thread while invalidate_image_cache() is called. possible fix for #6478 --- libs/canvas/canvas/wave_view.h | 1 + libs/canvas/wave_view.cc | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h index e9df823a9c..51c14c1d2e 100644 --- a/libs/canvas/canvas/wave_view.h +++ b/libs/canvas/canvas/wave_view.h @@ -401,6 +401,7 @@ public: static gint drawing_thread_should_quit; static Glib::Threads::Mutex request_queue_lock; + static Glib::Threads::Mutex current_image_lock; static Glib::Threads::Cond request_cond; static Glib::Threads::Thread* _drawing_thread; typedef std::set DrawingRequestQueue; diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc index a06ec1090a..6fab308a54 100644 --- a/libs/canvas/wave_view.cc +++ b/libs/canvas/wave_view.cc @@ -65,6 +65,7 @@ double WaveView::_clip_level = 0.98853; WaveViewCache* WaveView::images = 0; gint WaveView::drawing_thread_should_quit = 0; Glib::Threads::Mutex WaveView::request_queue_lock; +Glib::Threads::Mutex WaveView::current_image_lock; Glib::Threads::Cond WaveView::request_cond; Glib::Threads::Thread* WaveView::_drawing_thread = 0; WaveView::DrawingRequestQueue WaveView::request_queue; @@ -263,6 +264,7 @@ WaveView::invalidate_image_cache () { DEBUG_TRACE (DEBUG::WaveView, string_compose ("%1 invalidates image cache and cancels current request\n", this)); cancel_my_render_request (); + Glib::Threads::Mutex::Lock lci (current_image_lock); _current_image.reset (); } @@ -1119,6 +1121,7 @@ WaveView::render (Rect const & area, Cairo::RefPtr context) cons double image_origin_in_self_coordinates; boost::shared_ptr image_to_draw; + Glib::Threads::Mutex::Lock lci (current_image_lock); if (_current_image) { /* check it covers the right sample range */ @@ -1181,6 +1184,7 @@ WaveView::render (Rect const & area, Cairo::RefPtr context) cons double draw_width; if (image_to_draw != _current_image) { + lci.release (); /* the image is guaranteed to start at or before * draw_start. But if it starts before draw_start, that reduces