diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index f2b07c51e..cd438ebe5 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -1,6 +1,7 @@ #include "BackgroundSlicingProcess.hpp" #include "GUI_App.hpp" +#include #include #include #include @@ -103,6 +104,15 @@ void BackgroundSlicingProcess::thread_proc() // End of the background processing thread. The UI thread should join m_thread now. } +void BackgroundSlicingProcess::thread_proc_safe() +{ + try { + this->thread_proc(); + } catch (...) { + wxTheApp->OnUnhandledException(); + } +} + void BackgroundSlicingProcess::join_background_thread() { std::unique_lock lck(m_mutex); @@ -127,7 +137,7 @@ bool BackgroundSlicingProcess::start() if (m_state == STATE_INITIAL) { // The worker thread is not running yet. Start it. assert(! m_thread.joinable()); - m_thread = std::thread([this]{this->thread_proc();}); + m_thread = std::thread([this]{this->thread_proc_safe();}); // Wait until the worker thread is ready to execute the background processing task. m_condition.wait(lck, [this](){ return m_state == STATE_IDLE; }); } diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.hpp b/src/slic3r/GUI/BackgroundSlicingProcess.hpp index f00668299..6b92e8516 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.hpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.hpp @@ -80,6 +80,7 @@ public: private: void thread_proc(); + void thread_proc_safe(); void join_background_thread(); // To be called by Print::apply() through the Print::m_cancel_callback to stop the background // processing before changing any data of running or finalized milestones.