Add timeout for plater stopping the UI jobs.

This commit is contained in:
tamasmeszaros 2021-12-03 10:40:41 +01:00
parent 35ca045b1c
commit 7eeffd6dca
2 changed files with 12 additions and 6 deletions

View File

@ -100,18 +100,18 @@ template<class...Args> bool replace_job(Worker &w, Args&& ...args)
}
// Cancel the current job and wait for it to actually be stopped.
inline void stop_current_job(Worker &w, unsigned timeout_ms = 0)
inline bool stop_current_job(Worker &w, unsigned timeout_ms = 0)
{
w.cancel();
w.wait_for_current_job(timeout_ms);
return w.wait_for_current_job(timeout_ms);
}
// Cancel all pending jobs including current one and wait until the worker
// becomes idle.
inline void stop_queue(Worker &w, unsigned timeout_ms = 0)
inline bool stop_queue(Worker &w, unsigned timeout_ms = 0)
{
w.cancel_all();
w.wait_for_idle(timeout_ms);
return w.wait_for_idle(timeout_ms);
}
}} // namespace Slic3r::GUI

View File

@ -5892,8 +5892,14 @@ void Plater::reslice()
if (canvas3D()->get_gizmos_manager().is_in_editing_mode(true))
return;
// Stop arrange and (or) optimize rotation tasks.
stop_queue(this->get_ui_job_worker());
// Stop the running (and queued) UI jobs and only proceed if they actually
// get stopped.
unsigned timeout_ms = 10000;
if (!stop_queue(this->get_ui_job_worker(), timeout_ms)) {
BOOST_LOG_TRIVIAL(error) << "Could not stop UI job within "
<< timeout_ms << " milliseconds timeout!";
return;
}
if (printer_technology() == ptSLA) {
for (auto& object : model().objects)