Keep the preset sync thread away from the app while it shuts down

Closing Orca while the startup sync of presets and plugins was running
crashed on exit. The threads only saw their cancel flag once
~PresetUpdater ran, after the main window with its plater and the app
config were gone, and the sync thread checked it in a few places only,
so it went on to call into them. Read the app settings it needs before
starting the thread, make the flag atomic and check it at each step,
and stop and join the threads when the main window closes, and again in
GUI_App::OnExit().

Ported from bambulab/BambuStudio@fc560922da

Co-authored-by: baijie <tonghao.yuan@bambulab.com>
This commit is contained in:
Ian Bassiandbaijie committed 2026-11-30 14:12:40 -03:00
1 parent 9b8eeb1a40
commit 5cdf5bf8fa
4 files changed
+37 -8

No files matched your search

+4
View File
@@ -116,6 +116,7 @@
#include "BindDialog.hpp"
#include "../Utils/MacDarkMode.hpp"
#include "../Utils/NetworkAgentFactory.hpp"
#include "../Utils/PresetUpdater.hpp"
#include "../Utils/PrintHost.hpp"
#include "GUI_App.hpp"
@@ -755,6 +756,9 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
// Prevent queued selection/UI refresh work from running as normal during reset.
wxGetApp().set_closing(true);
wxGetApp().start_exit_watchdog();
// The preset sync threads use the plater, which is deleted with this window.
if (PresetUpdater* updater = wxGetApp().get_preset_updater())
updater->stop();
m_plater->reset();
this->shutdown();