From 56a61bfcf5eb31bd87c178a1e4311ef79a03f3ee Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Fri, 26 Aug 2022 15:24:02 +0800 Subject: [PATCH] FIX: record dialog stack and EndModal on system session end Change-Id: Ie0a7de7cf467f5b9e88881d3894dbb7a0790d500 --- src/slic3r/GUI/GUI_App.cpp | 5 +++++ src/slic3r/GUI/GUI_Utils.cpp | 2 ++ src/slic3r/GUI/GUI_Utils.hpp | 10 ++++++++++ 3 files changed, 17 insertions(+) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index a04ff5ff5..70d24430a 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1835,6 +1835,11 @@ bool GUI_App::on_init_inner() //BBS set crash log folder CBaseException::set_log_folder(data_dir()); #endif + + wxGetApp().Bind(wxEVT_QUERY_END_SESSION, [](auto & e) { + for (auto d : dialogStack) + d->EndModal(1); + }); std::map extra_headers = get_extra_header(); Slic3r::Http::set_extra_headers(extra_headers); diff --git a/src/slic3r/GUI/GUI_Utils.cpp b/src/slic3r/GUI/GUI_Utils.cpp index 1c472f420..3d579a363 100644 --- a/src/slic3r/GUI/GUI_Utils.cpp +++ b/src/slic3r/GUI/GUI_Utils.cpp @@ -469,5 +469,7 @@ bool generate_image(const std::string &filename, wxImage &image, wxSize img_size return true; } +std::vector dialogStack; + } } diff --git a/src/slic3r/GUI/GUI_Utils.hpp b/src/slic3r/GUI/GUI_Utils.hpp index 6daa308c2..9ea6d33dc 100644 --- a/src/slic3r/GUI/GUI_Utils.hpp +++ b/src/slic3r/GUI/GUI_Utils.hpp @@ -104,6 +104,8 @@ struct DpiChangedEvent : public wxEvent { wxDECLARE_EVENT(EVT_DPI_CHANGED_SLICER, DpiChangedEvent); #endif // !wxVERSION_EQUAL_OR_GREATER_THAN +extern std::vector dialogStack; + template class DPIAware : public P { public: @@ -221,6 +223,14 @@ public: on_sys_color_changed(); } #endif + + int ShowModal() + { + dialogStack.push_back(this); + int r = wxDialog::ShowModal(); + dialogStack.pop_back(); + return r; + } protected: virtual void on_dpi_changed(const wxRect &suggested_rect) = 0;