mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-21 15:44:28 +08:00
Fix PlaterWorker not calling yield from main thread
Also fix UIThreadWorker not setting busy cursor
This commit is contained in:
parent
fe9ad66e84
commit
cf16dafad9
@ -38,22 +38,24 @@ class PlaterWorker: public Worker {
|
|||||||
|
|
||||||
void update_status(int st, const std::string &msg = "") override
|
void update_status(int st, const std::string &msg = "") override
|
||||||
{
|
{
|
||||||
wxWakeUpIdle();
|
|
||||||
ctl.update_status(st, msg);
|
ctl.update_status(st, msg);
|
||||||
|
|
||||||
// If the worker is not using additional threads, the UI
|
// If the worker is not using additional threads, the UI
|
||||||
// is refreshed with this call. If the worker is running
|
// is refreshed with this call. If the worker is running
|
||||||
// in it's own thread, the yield should not have any
|
// in it's own thread, this will be one additional
|
||||||
// visible effects.
|
// evaluation of the event loop which should have no visible
|
||||||
wxYieldIfNeeded();
|
// effects.
|
||||||
|
call_on_main_thread([] { wxYieldIfNeeded(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool was_canceled() const override { return ctl.was_canceled(); }
|
bool was_canceled() const override { return ctl.was_canceled(); }
|
||||||
|
|
||||||
std::future<void> call_on_main_thread(std::function<void()> fn) override
|
std::future<void> call_on_main_thread(std::function<void()> fn) override
|
||||||
{
|
{
|
||||||
|
auto ftr = ctl.call_on_main_thread(std::move(fn));
|
||||||
wxWakeUpIdle();
|
wxWakeUpIdle();
|
||||||
return ctl.call_on_main_thread(std::move(fn));
|
|
||||||
|
return ftr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} wctl{c};
|
} wctl{c};
|
||||||
|
@ -62,7 +62,15 @@ protected:
|
|||||||
|
|
||||||
std::future<void> call_on_main_thread(std::function<void()> fn) override
|
std::future<void> call_on_main_thread(std::function<void()> fn) override
|
||||||
{
|
{
|
||||||
return std::async(std::launch::deferred, [fn]{ fn(); });
|
std::future<void> 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:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user