diff --git a/src/slic3r/GUI/Jobs/PlaterWorker.hpp b/src/slic3r/GUI/Jobs/PlaterWorker.hpp index 58bd1ec32b..0fef3655e5 100644 --- a/src/slic3r/GUI/Jobs/PlaterWorker.hpp +++ b/src/slic3r/GUI/Jobs/PlaterWorker.hpp @@ -38,22 +38,24 @@ class PlaterWorker: public Worker { void update_status(int st, const std::string &msg = "") override { - wxWakeUpIdle(); ctl.update_status(st, msg); // If the worker is not using additional threads, the UI // is refreshed with this call. If the worker is running - // in it's own thread, the yield should not have any - // visible effects. - wxYieldIfNeeded(); + // in it's own thread, this will be one additional + // evaluation of the event loop which should have no visible + // effects. + call_on_main_thread([] { wxYieldIfNeeded(); }); } bool was_canceled() const override { return ctl.was_canceled(); } std::future call_on_main_thread(std::function fn) override { + auto ftr = ctl.call_on_main_thread(std::move(fn)); wxWakeUpIdle(); - return ctl.call_on_main_thread(std::move(fn)); + + return ftr; } } wctl{c}; diff --git a/src/slic3r/GUI/Jobs/UIThreadWorker.hpp b/src/slic3r/GUI/Jobs/UIThreadWorker.hpp index 610d205cf9..91213c2391 100644 --- a/src/slic3r/GUI/Jobs/UIThreadWorker.hpp +++ b/src/slic3r/GUI/Jobs/UIThreadWorker.hpp @@ -62,7 +62,15 @@ protected: std::future call_on_main_thread(std::function fn) override { - return std::async(std::launch::deferred, [fn]{ fn(); }); + std::future ftr = std::async(std::launch::deferred, [fn]{ fn(); }); + + // So, it seems that the destructor of std::future will not call the + // packaged function. The future needs to be accessed at least ones + // or waited upon. Calling wait() instead of get() will keep the + // returned future's state valid. + ftr.wait(); + + return ftr; } public: