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"));