FIX: shutdown GUI_App after confirm dialog

Change-Id: Ie379e9e764f43be1592a74b929bfbfc1d2d41a49
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2022-07-25 18:10:52 +08:00 committed by Lane.Wei
parent e0c4453c46
commit a9fd7c762e
3 changed files with 19 additions and 14 deletions

View File

@ -1105,6 +1105,23 @@ GUI_App::GUI_App()
reset_to_active(); 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) 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()); const std::string name = into_u8(window->GetName());
window->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent &event) { window->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent &event) {
m_is_closing = true;
window_pos_save(window, "mainframe"); 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(); event.Skip();
}); });

View File

@ -280,6 +280,7 @@ public:
// Process command line parameters cached in this->init_params, // Process command line parameters cached in this->init_params,
// load configs, STLs etc. // load configs, STLs etc.
void post_init(); void post_init();
void shutdown();
// If formatted for github, plaintext with OpenGL extensions enclosed into <details>. // If formatted for github, plaintext with OpenGL extensions enclosed into <details>.
// Otherwise HTML formatted for the system info dialog. // Otherwise HTML formatted for the system info dialog.
static std::string get_gl_info(bool for_github); static std::string get_gl_info(bool for_github);

View File

@ -700,6 +700,7 @@ void MainFrame::shutdown()
// to avoid any manipulations with them from App->wxEVT_IDLE after of the mainframe closing // to avoid any manipulations with them from App->wxEVT_IDLE after of the mainframe closing
wxGetApp().tabs_list.clear(); wxGetApp().tabs_list.clear();
wxGetApp().model_tabs_list.clear(); wxGetApp().model_tabs_list.clear();
wxGetApp().shutdown();
// BBS: why clear ? // BBS: why clear ?
//wxGetApp().plater_ = nullptr; //wxGetApp().plater_ = nullptr;
} }