Prevent accidental stopping of BoostThreadWorker before destruction

This commit is contained in:
tamasmeszaros 2021-12-01 10:02:01 +01:00
parent 2b25c6fab2
commit a802bdc764

View File

@ -94,9 +94,9 @@ constexpr int ABORT_WAIT_MAX_MS = 10000;
BoostThreadWorker::~BoostThreadWorker() BoostThreadWorker::~BoostThreadWorker()
{ {
replace_job(*this, nullptr);
try { try {
cancel_all();
m_input_queue.push(JobEntry{nullptr});
join(ABORT_WAIT_MAX_MS); join(ABORT_WAIT_MAX_MS);
} catch(...) { } catch(...) {
BOOST_LOG_TRIVIAL(error) BOOST_LOG_TRIVIAL(error)
@ -130,8 +130,10 @@ void BoostThreadWorker::process_events()
bool BoostThreadWorker::start_next(std::unique_ptr<Job> job) bool BoostThreadWorker::start_next(std::unique_ptr<Job> job)
{ {
m_input_queue.push(JobEntry{std::move(job)}); if (job)
return true; m_input_queue.push(JobEntry{std::move(job)});
return bool{job};
} }
}} // namespace Slic3r::GUI }} // namespace Slic3r::GUI