From de712b08f11138f650f5cf506899606a7782bb7d Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Tue, 30 Aug 2022 10:57:12 +0800 Subject: [PATCH] FIX: crash on MacOS when system logout, not really Close mainframe Change-Id: I0e7cc73c1b4bbc663105034e82dcd7a51998e244 --- src/slic3r/GUI/GUI_App.cpp | 11 ++++++++++- src/slic3r/GUI/GUI_Utils.cpp | 2 +- src/slic3r/GUI/GUI_Utils.hpp | 6 +++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 70d24430a..c103c7709 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1836,7 +1836,16 @@ bool GUI_App::on_init_inner() CBaseException::set_log_folder(data_dir()); #endif - wxGetApp().Bind(wxEVT_QUERY_END_SESSION, [](auto & e) { + wxGetApp().Bind(wxEVT_QUERY_END_SESSION, [this](auto & e) { + if (mainframe) { + wxCloseEvent e2(wxEVT_CLOSE_WINDOW); + e2.SetCanVeto(true); + mainframe->GetEventHandler()->ProcessEvent(e2); + if (e2.GetVeto()) { + e.Veto(); + return; + } + } for (auto d : dialogStack) d->EndModal(1); }); diff --git a/src/slic3r/GUI/GUI_Utils.cpp b/src/slic3r/GUI/GUI_Utils.cpp index 3d579a363..0667e164c 100644 --- a/src/slic3r/GUI/GUI_Utils.cpp +++ b/src/slic3r/GUI/GUI_Utils.cpp @@ -469,7 +469,7 @@ bool generate_image(const std::string &filename, wxImage &image, wxSize img_size return true; } -std::vector dialogStack; +std::deque dialogStack; } } diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index 9ea6d33dc..a93009129 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -104,7 +104,7 @@ struct DpiChangedEvent : public wxEvent { wxDECLARE_EVENT(EVT_DPI_CHANGED_SLICER, DpiChangedEvent); #endif // !wxVERSION_EQUAL_OR_GREATER_THAN -extern std::vector dialogStack; +extern std::deque dialogStack; template class DPIAware : public P { @@ -226,9 +226,9 @@ public: int ShowModal() { - dialogStack.push_back(this); + dialogStack.push_front(this); int r = wxDialog::ShowModal(); - dialogStack.pop_back(); + dialogStack.pop_front(); return r; }