From 04a9aecf014a5e7735ebe5bfc30a98773b5a5fe2 Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Fri, 23 Oct 2026 15:48:59 +0800 Subject: [PATCH] Let OrcaSlicer Exit After a Device Warning Dialog Was Shown (#16764) wx leaves the main loop only when no other top-level window exists, hidden ones included. The unsupported-control and chamber temperature warnings were parentless frames that are hidden, never destroyed, and the printer parts dialog was heap-allocated without being destroyed, so after any of them had been shown the process stayed alive once the main window closed. Parent the warnings to the main frame and put the parts dialog on the stack. --- src/slic3r/GUI/DeviceManager.cpp | 8 ++++++-- src/slic3r/GUI/Plater.cpp | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index b6c191c1df..bdfcfe02fd 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -11,6 +11,7 @@ #include "GUI_App.hpp" #include "DeviceErrorDialog.hpp" +#include "MainFrame.hpp" #include "Plater.hpp" #include "ReleaseNote.hpp" #include @@ -4751,7 +4752,9 @@ int MachineObject::parse_json(std::string tunnel, std::string payload, bool key_ void MachineObject::set_ctt_dlg( wxString text){ if (!m_set_ctt_dlg) { m_set_ctt_dlg = true; - auto print_error_dlg = new GUI::SecondaryCheckDialog(nullptr, wxID_ANY, _L("Warning"), GUI::SecondaryCheckDialog::VisibleButtons::ONLY_CONFIRM); // ORCA VisibleButtons instead ButtonStyle + // Parented so it is destroyed with the main frame: a parentless top-level window, + // even hidden, keeps wx from leaving the event loop on exit. + auto print_error_dlg = new GUI::SecondaryCheckDialog(GUI::wxGetApp().mainframe, wxID_ANY, _L("Warning"), GUI::SecondaryCheckDialog::VisibleButtons::ONLY_CONFIRM); // ORCA VisibleButtons instead ButtonStyle print_error_dlg->update_text(text); print_error_dlg->Bind(wxEVT_SHOW, [this](auto& e) { if (!e.IsShown()) { @@ -4786,7 +4789,8 @@ void MachineObject::show_unsupported_dlg(int code) // note: constructed directly rather than through CallAfter because every publish_json caller // is on the UI thread - clicks come from wx handlers, and the agent marshals its own push // callbacks back to main before parse_json runs. set_ctt_dlg relies on the same property. - auto unsupported_dlg = new GUI::SecondaryCheckDialog(nullptr, wxID_ANY, _L("Warning"), + // Parented for the same reason as in set_ctt_dlg. + auto unsupported_dlg = new GUI::SecondaryCheckDialog(GUI::wxGetApp().mainframe, wxID_ANY, _L("Warning"), GUI::SecondaryCheckDialog::VisibleButtons::ONLY_CONFIRM); unsupported_dlg->update_text(text); unsupported_dlg->Bind(wxEVT_SHOW, [this](auto& e) { diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d2096d2550..80965cf970 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -19970,9 +19970,9 @@ bool Plater::check_printer_initialized(MachineObject *obj, bool only_warning, bo dlg.ShowModal(); } - PrinterPartsDialog *print_parts_dlg = new PrinterPartsDialog(nullptr); - print_parts_dlg->update_machine_obj(obj); - print_parts_dlg->ShowModal(); + PrinterPartsDialog print_parts_dlg(nullptr); + print_parts_dlg.update_machine_obj(obj); + print_parts_dlg.ShowModal(); } else { auto printer_name = get_selected_printer_name_in_combox(); // wxString(obj->get_preset_printer_model_name(machine_print_name)) pop_warning_and_go_to_device_page(printer_name, Plater::PrinterWarningType::NOT_CONNECTED, _L("Sync printer information"));