From 7fd6e5fd723ef9133530a8a8fbac7cbb2e12f408 Mon Sep 17 00:00:00 2001 From: Ioannis Giannakas <59056762+igiannakas@users.noreply.github.com> Date: Sun, 4 Oct 2026 21:54:47 +0100 Subject: [PATCH] Fix crash on macOS when OrcaSlicer is quit from the Dock, a logout or a restart (#16136) Fix crash when quitting from the Dock, logout or restart on macOS --- src/slic3r/GUI/GUI_App.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 94ef20e9fd..73a58c5b51 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3087,6 +3087,18 @@ bool GUI_App::on_init_inner() d->EndModal(wxID_ABORT); }); +#ifdef __APPLE__ + // A quit request from the Dock, a logout or a restart ends with AppKit calling exit() right after this event, so + // OnExit() and ~GUI_App() never run. Shut the plugins and Python down here as ~GUI_App() does. Left to + // PluginManager's static destructor, the shutdown locks hook state that has already been destroyed and aborts. + wxGetApp().Bind(wxEVT_END_SESSION, [](wxCloseEvent &e) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "received wxEVT_END_SESSION"; + Slic3r::PluginManager::instance().shutdown(); + Slic3r::PythonInterpreter::instance().shutdown(); + e.Skip(); + }); +#endif + // Verify resources path const wxString resources_dir = from_u8(Slic3r::resources_dir()); wxCHECK_MSG(wxDirExists(resources_dir), false,