From: Carl Hetherington Date: Mon, 22 Jul 2013 07:52:02 +0000 (+0100) Subject: Try to fix deadlock. X-Git-Tag: v2.0.48~1337^2~169 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=c9c01e5035c0b625fad840c209d6e76ea371a6f9;p=dcpomatic.git Try to fix deadlock. --- diff --git a/src/lib/job.cc b/src/lib/job.cc index 18df40878..e63ea6dc8 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -179,15 +179,21 @@ Job::paused () const void Job::set_state (State s) { - boost::mutex::scoped_lock lm (_state_mutex); - _state = s; + bool finished = false; + + { + boost::mutex::scoped_lock lm (_state_mutex); + _state = s; - if (_state == FINISHED_OK || _state == FINISHED_ERROR || _state == FINISHED_CANCELLED) { - _ran_for = elapsed_time (); - if (ui_signaller) { - ui_signaller->emit (boost::bind (boost::ref (Finished))); + if (_state == FINISHED_OK || _state == FINISHED_ERROR || _state == FINISHED_CANCELLED) { + _ran_for = elapsed_time (); + finished = true; } } + + if (finished && ui_signaller) { + ui_signaller->emit (boost::bind (boost::ref (Finished))); + } } /** @return Time (in seconds) that this job has been running */