From 10643779b6f039a7458bd0c970ef40ac80ea0568 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 11 Jun 2015 17:04:08 -0400 Subject: more refactoring of WaveView threaded code to try to get to heart of crash bug --- libs/canvas/wave_view.cc | 77 ++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 38 deletions(-) (limited to 'libs/canvas/wave_view.cc') diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc index 6dc5c71726..52f6ee9f33 100644 --- a/libs/canvas/wave_view.cc +++ b/libs/canvas/wave_view.cc @@ -861,9 +861,47 @@ WaveView::queue_get_image (boost::shared_ptr region, frame req->fill_color = _fill_color; req->region_amplitude = _region_amplitude; - send_request (req); + if (current_request) { + /* this will stop rendering in progress (which might otherwise + be long lived) for any current request. + */ + current_request->cancel (); + } + + start_drawing_thread (); + + /* swap requests (protected by lock) */ + + { + Glib::Threads::Mutex::Lock lm (request_queue_lock); + current_request = req; + } + + /* this is always called from the GUI thread (there is only one), and + * the same thread runs the idle callback chain. thus we do not need + * any locks to protect idle_queued - it is only ever set or read in + * the unitary GUI thread. + */ + + if (!idle_queued) { + Glib::signal_idle().connect (sigc::mem_fun (*this, &WaveView::idle_send_request)); + idle_queued = true; + } } +bool +WaveView::idle_send_request () const +{ + Glib::Threads::Mutex::Lock lm (request_queue_lock); + + request_queue.insert (this); + request_cond.signal (); /* wake thread - must be done while holding lock */ + idle_queued = false; + + return false; /* do not call from idle again */ +} + + void WaveView::generate_image (boost::shared_ptr req, bool in_render_thread) const { @@ -1371,43 +1409,6 @@ WaveView::cancel_my_render_request () const current_request.reset (); } -void -WaveView::send_request (boost::shared_ptr req) const -{ - if (req->type == WaveViewThreadRequest::Draw && current_request) { - /* this will stop rendering in progress (which might otherwise - be long lived) for any current request. - */ - current_request->cancel (); - } - - start_drawing_thread (); - - /* this is always called from the GUI thread (there is only one), and - * the same thread runs the idle callback chain. thus we do not need - * any locks to protect idle_queued - it is only ever set or read in - * the unitary GUI thread. - */ - - if (!idle_queued) { - Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (*this, &WaveView::idle_send_request), req)); - idle_queued = true; - } -} - -bool -WaveView::idle_send_request (boost::shared_ptr req) const -{ - Glib::Threads::Mutex::Lock lm (request_queue_lock); - /* swap requests (protected by lock) */ - current_request = req; - request_queue.insert (this); - request_cond.signal (); /* wake thread - must be done while holding lock */ - idle_queued = false; - - return false; /* do not call from idle again */ -} - /*-------------------------------------------------*/ void -- cgit v1.2.3