From a9fd7c762ef48994b2820f060bcfd405b55884b7 Mon Sep 17 00:00:00 2001 From: Stone Li Date: Mon, 25 Jul 2022 18:10:52 +0800 Subject: [PATCH] FIX: shutdown GUI_App after confirm dialog Change-Id: Ie379e9e764f43be1592a74b929bfbfc1d2d41a49 Signed-off-by: Stone Li --- src/slic3r/GUI/GUI_App.cpp | 31 +++++++++++++++++-------------- src/slic3r/GUI/GUI_App.hpp | 1 + src/slic3r/GUI/MainFrame.cpp | 1 + 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 1bade7562..35023163b 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1105,6 +1105,23 @@ GUI_App::GUI_App() reset_to_active(); } +void GUI_App::shutdown() +{ + m_is_closing = true; + stop_sync_user_preset(); + + if (m_device_manager) { + delete m_device_manager; + m_device_manager = nullptr; + } + + if (m_agent) { + m_agent->start_discovery(false, false); + delete m_agent; + m_agent = nullptr; + } +} + std::string GUI_App::get_http_url(std::string country_code) { @@ -2703,21 +2720,7 @@ void GUI_App::persist_window_geometry(wxTopLevelWindow *window, bool default_max const std::string name = into_u8(window->GetName()); window->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent &event) { - m_is_closing = true; window_pos_save(window, "mainframe"); - // - stop_sync_user_preset(); - - if (m_device_manager) { - delete m_device_manager; - m_device_manager = nullptr; - } - - if (m_agent) { - m_agent->start_discovery(false, false); - delete m_agent; - m_agent = nullptr; - } event.Skip(); }); diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 4aeea2e0c..af2b4e134 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -280,6 +280,7 @@ public: // Process command line parameters cached in this->init_params, // load configs, STLs etc. void post_init(); + void shutdown(); // If formatted for github, plaintext with OpenGL extensions enclosed into
. // Otherwise HTML formatted for the system info dialog. static std::string get_gl_info(bool for_github); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 2daa17345..b46923093 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -700,6 +700,7 @@ void MainFrame::shutdown() // to avoid any manipulations with them from App->wxEVT_IDLE after of the mainframe closing wxGetApp().tabs_list.clear(); wxGetApp().model_tabs_list.clear(); + wxGetApp().shutdown(); // BBS: why clear ? //wxGetApp().plater_ = nullptr; }