diff --git a/src/slic3r/GUI/CalibrationPanel.cpp b/src/slic3r/GUI/CalibrationPanel.cpp index 54b8862d2..858394aee 100644 --- a/src/slic3r/GUI/CalibrationPanel.cpp +++ b/src/slic3r/GUI/CalibrationPanel.cpp @@ -242,21 +242,26 @@ void SelectMObjectPopup::Popup(wxWindow* WXUNUSED(focus)) if (wxGetApp().is_user_login()) { if (!get_print_info_thread) { - get_print_info_thread = new boost::thread(Slic3r::create_thread([&] { + get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr(m_token)] { NetworkAgent* agent = wxGetApp().getAgent(); unsigned int http_code; std::string body; int result = agent->get_user_print_info(&http_code, &body); - if (result == 0) { - m_print_info = body; - } - else { - m_print_info = ""; - } - wxCommandEvent event(EVT_UPDATE_USER_MLIST); - event.SetEventObject(this); - wxPostEvent(this, event); - })); + + wxGetApp().CallAfter([token, this, result, body]() { + if (token.expired()) {return;} + if (result == 0) { + m_print_info = body; + } + else { + m_print_info = ""; + } + + wxCommandEvent event(EVT_UPDATE_USER_MLIST); + event.SetEventObject(this); + wxPostEvent(this, event); + }); + })); } } diff --git a/src/slic3r/GUI/CalibrationPanel.hpp b/src/slic3r/GUI/CalibrationPanel.hpp index ca55e07f1..a1c23e0e6 100644 --- a/src/slic3r/GUI/CalibrationPanel.hpp +++ b/src/slic3r/GUI/CalibrationPanel.hpp @@ -89,6 +89,7 @@ private: std::vector m_user_list_machine_panel; boost::thread* get_print_info_thread{ nullptr }; std::string m_print_info; + std::shared_ptr m_token = std::make_shared(0); std::map m_bind_machine_list; private: diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index bdcf2730d..19d8c3bd8 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1255,7 +1255,7 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent) m_sizer_body->Add(m_trouble_shoot, 0, wxLEFT | wxRIGHT | wxEXPAND, FromDIP(40)); m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(8)); - m_sizer_body->Add(m_sizer_button, 0, wxRIGHT | wxEXPAND, FromDIP(18)); + m_sizer_body->Add(m_sizer_button, 0, wxRIGHT | wxEXPAND, FromDIP(25)); m_sizer_body->Layout(); SetSizer(m_sizer_body); diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 1a41842d0..9389b513f 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -429,19 +429,23 @@ void SelectMachinePopup::Popup(wxWindow *WXUNUSED(focus)) if (wxGetApp().is_user_login()) { if (!get_print_info_thread) { - get_print_info_thread = new boost::thread(Slic3r::create_thread([&] { + get_print_info_thread = new boost::thread(Slic3r::create_thread([this, token = std::weak_ptr(m_token)] { NetworkAgent* agent = wxGetApp().getAgent(); unsigned int http_code; std::string body; int result = agent->get_user_print_info(&http_code, &body); - if (result == 0) { - m_print_info = body; - } else { - m_print_info = ""; - } - wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST); - event.SetEventObject(this); - wxPostEvent(this, event); + CallAfter([token, this, result, body]() { + if (token.expired()) {return;} + if (result == 0) { + m_print_info = body; + } + else { + m_print_info = ""; + } + wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST); + event.SetEventObject(this); + wxPostEvent(this, event); + }); })); } } @@ -2828,20 +2832,23 @@ void SelectMachineDialog::update_user_machine_list() { NetworkAgent* m_agent = wxGetApp().getAgent(); if (m_agent && m_agent->is_user_login()) { - boost::thread get_print_info_thread = Slic3r::create_thread([&] { + boost::thread get_print_info_thread = Slic3r::create_thread([this, token = std::weak_ptr(m_token)] { NetworkAgent* agent = wxGetApp().getAgent(); unsigned int http_code; std::string body; int result = agent->get_user_print_info(&http_code, &body); - if (result == 0) { - m_print_info = body; - } - else { - m_print_info = ""; - } - wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST); - event.SetEventObject(this); - wxPostEvent(this, event); + CallAfter([token, this, result, body] { + if (token.expired()) {return;} + if (result == 0) { + m_print_info = body; + } + else { + m_print_info = ""; + } + wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST); + event.SetEventObject(this); + wxPostEvent(this, event); + }); }); } else { wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST); diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index beaebfd42..45e3bab67 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -215,7 +215,8 @@ private: std::vector m_user_list_machine_panel; std::vector m_other_list_machine_panel; boost::thread* get_print_info_thread{ nullptr }; - std::string m_print_info; + std::shared_ptr m_token = std::make_shared(0); + std::string m_print_info = ""; bool m_dismiss { false }; std::map m_bind_machine_list; @@ -304,6 +305,7 @@ private: wxColour m_colour_bold_color{wxColour(38, 46, 48)}; StateColor m_btn_bg_enable; + std::shared_ptr m_token = std::make_shared(0); std::map m_checkbox_list; //std::map m_checkbox_state_list; std::vector m_bedtype_list; diff --git a/src/slic3r/GUI/SendToPrinter.cpp b/src/slic3r/GUI/SendToPrinter.cpp index 7ae14888d..c8d08c286 100644 --- a/src/slic3r/GUI/SendToPrinter.cpp +++ b/src/slic3r/GUI/SendToPrinter.cpp @@ -824,20 +824,23 @@ void SendToPrinterDialog::update_user_machine_list() { NetworkAgent* m_agent = wxGetApp().getAgent(); if (m_agent && m_agent->is_user_login()) { - boost::thread get_print_info_thread = Slic3r::create_thread([&] { + boost::thread get_print_info_thread = Slic3r::create_thread([this, token = std::weak_ptr(m_token)] { NetworkAgent* agent = wxGetApp().getAgent(); unsigned int http_code; std::string body; int result = agent->get_user_print_info(&http_code, &body); - if (result == 0) { - m_print_info = body; - } - else { - m_print_info = ""; - } - wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST); - event.SetEventObject(this); - wxPostEvent(this, event); + CallAfter([token, this, result, body] { + if (token.expired()) {return;} + if (result == 0) { + m_print_info = body; + } + else { + m_print_info = ""; + } + wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST); + event.SetEventObject(this); + wxPostEvent(this, event); + }); }); } else { wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST); diff --git a/src/slic3r/GUI/SendToPrinter.hpp b/src/slic3r/GUI/SendToPrinter.hpp index 59984ab5d..6b348c665 100644 --- a/src/slic3r/GUI/SendToPrinter.hpp +++ b/src/slic3r/GUI/SendToPrinter.hpp @@ -114,7 +114,7 @@ private: wxTimer* m_refresh_timer{ nullptr }; std::shared_ptr m_status_bar; wxScrolledWindow* m_sw_print_failed_info{nullptr}; - + std::shared_ptr m_token = std::make_shared(0); public: SendToPrinterDialog(Plater* plater = nullptr); diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index f8e240b12..9b8689a2e 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -2733,9 +2733,11 @@ void StatusPanel::update_basic_print_data(bool def) void StatusPanel::update_model_info() { auto get_subtask_fn = [this](BBLModelTask* subtask) { - if (obj && obj->subtask_id_ == subtask->task_id) { - obj->set_modeltask(subtask); - } + CallAfter([this, subtask]() { + if (obj && obj->subtask_id_ == subtask->task_id) { + obj->set_modeltask(subtask); + } + }); };