From: Carl Hetherington Date: Sun, 3 Jul 2016 19:36:20 +0000 (+0100) Subject: Remove several exception-throwing asserts from destructors. X-Git-Tag: v2.8.17~9 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=8862cbbb7e857c90d405069ad7d41a8d58029194 Remove several exception-throwing asserts from destructors. --- diff --git a/src/lib/encode_server.cc b/src/lib/encode_server.cc index f318da03b..7e0152003 100644 --- a/src/lib/encode_server.cc +++ b/src/lib/encode_server.cc @@ -85,15 +85,23 @@ EncodeServer::~EncodeServer () } BOOST_FOREACH (boost::thread* i, _worker_threads) { - DCPOMATIC_ASSERT (i->joinable ()); - i->join (); + /* Ideally this would be a DCPOMATIC_ASSERT(i->joinable()) but we + can't throw exceptions from a destructor. + */ + if (i->joinable ()) { + i->join (); + } delete i; } _broadcast.io_service.stop (); if (_broadcast.thread) { - DCPOMATIC_ASSERT (_broadcast.thread->joinable ()); - _broadcast.thread->join (); + /* Ideally this would be a DCPOMATIC_ASSERT(_broadcast.thread->joinable()) but we + can't throw exceptions from a destructor. + */ + if (_broadcast.thread->joinable ()) { + _broadcast.thread->join (); + } } } diff --git a/src/lib/encode_server_finder.cc b/src/lib/encode_server_finder.cc index 7491d9ef7..eebf404fa 100644 --- a/src/lib/encode_server_finder.cc +++ b/src/lib/encode_server_finder.cc @@ -64,14 +64,22 @@ EncodeServerFinder::~EncodeServerFinder () _search_condition.notify_all (); if (_search_thread) { - DCPOMATIC_ASSERT (_search_thread->joinable ()); - _search_thread->join (); + /* Ideally this would be a DCPOMATIC_ASSERT(_search_thread->joinable()) but we + can't throw exceptions from a destructor. + */ + if (_search_thread->joinable ()) { + _search_thread->join (); + } } _listen_io_service.stop (); if (_listen_thread) { - DCPOMATIC_ASSERT (_listen_thread->joinable ()); - _listen_thread->join (); + /* Ideally this would be a DCPOMATIC_ASSERT(_listen_thread->joinable()) but we + can't throw exceptions from a destructor. + */ + if (_listen_thread->joinable ()) { + _listen_thread->join (); + } } } diff --git a/src/lib/job_manager.cc b/src/lib/job_manager.cc index 08c744e07..c9924d226 100644 --- a/src/lib/job_manager.cc +++ b/src/lib/job_manager.cc @@ -63,8 +63,12 @@ JobManager::~JobManager () } if (_scheduler) { - DCPOMATIC_ASSERT (_scheduler->joinable ()); - _scheduler->join (); + /* Ideally this would be a DCPOMATIC_ASSERT(_scheduler->joinable()) but we + can't throw exceptions from a destructor. + */ + if (_scheduler->joinable ()) { + _scheduler->join (); + } } delete _scheduler; diff --git a/src/lib/update_checker.cc b/src/lib/update_checker.cc index e3bbd663e..58bc7c1b7 100644 --- a/src/lib/update_checker.cc +++ b/src/lib/update_checker.cc @@ -86,8 +86,12 @@ UpdateChecker::~UpdateChecker () _condition.notify_all (); if (_thread) { - DCPOMATIC_ASSERT (_thread->joinable ()); - _thread->join (); + /* Ideally this would be a DCPOMATIC_ASSERT(_thread->joinable()) but we + can't throw exceptions from a destructor. + */ + if (_thread->joinable ()) { + _thread->join (); + } } delete _thread;