X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fjob.cc;h=0699c532c0fa4c69582bf954efa194b9b1ebcce4;hb=ebc36d56736997b40a51301a8746c6727cc34b1f;hp=75a5505a95d82c1e4e738b802cb739bc16c0d40f;hpb=3828baf56467224f5d44049bf1e7a7ed11f43a05;p=dcpomatic.git diff --git a/src/lib/job.cc b/src/lib/job.cc index 75a5505a9..0699c532c 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -62,8 +62,14 @@ Job::~Job () { if (_thread) { _thread->interrupt (); - DCPOMATIC_ASSERT (_thread->joinable ()); - _thread->join (); + /* We can't use DCPOMATIC_ASSERT here as it may throw an exception */ + if (_thread->joinable ()) { + try { + _thread->join (); + } catch (...) { + /* Too late to do anything about this */ + } + } } delete _thread; @@ -264,9 +270,19 @@ Job::elapsed_time () const void Job::set_progress (float p, bool force) { - if (!force && fabs (p - progress().get_value_or(0)) < 0.01) { - /* Calm excessive progress reporting */ - return; + if (!force) { + /* Check for excessively frequent progress reporting */ + boost::mutex::scoped_lock lm (_progress_mutex); + struct timeval now; + gettimeofday (&now, 0); + if (_last_progress_update && _last_progress_update->tv_sec > 0) { + double const elapsed = (now.tv_sec + now.tv_usec / 1000000.0) + - (_last_progress_update->tv_sec + _last_progress_update->tv_usec / 1000000.0); + if (elapsed < 0.5) { + return; + } + } + _last_progress_update = now; } set_progress_common (p);