ENH:add protection in threads
jira:[for random crash] Change-Id: I6286012dd77abccba461f7cd72a6fc531a84c95f
This commit is contained in:
parent
eb9cc0c9e5
commit
eaa7abf518
|
@ -242,21 +242,26 @@ void SelectMObjectPopup::Popup(wxWindow* WXUNUSED(focus))
|
||||||
|
|
||||||
if (wxGetApp().is_user_login()) {
|
if (wxGetApp().is_user_login()) {
|
||||||
if (!get_print_info_thread) {
|
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();
|
NetworkAgent* agent = wxGetApp().getAgent();
|
||||||
unsigned int http_code;
|
unsigned int http_code;
|
||||||
std::string body;
|
std::string body;
|
||||||
int result = agent->get_user_print_info(&http_code, &body);
|
int result = agent->get_user_print_info(&http_code, &body);
|
||||||
if (result == 0) {
|
|
||||||
m_print_info = body;
|
wxGetApp().CallAfter([token, this, result, body]() {
|
||||||
}
|
if (token.expired()) {return;}
|
||||||
else {
|
if (result == 0) {
|
||||||
m_print_info = "";
|
m_print_info = body;
|
||||||
}
|
}
|
||||||
wxCommandEvent event(EVT_UPDATE_USER_MLIST);
|
else {
|
||||||
event.SetEventObject(this);
|
m_print_info = "";
|
||||||
wxPostEvent(this, event);
|
}
|
||||||
}));
|
|
||||||
|
wxCommandEvent event(EVT_UPDATE_USER_MLIST);
|
||||||
|
event.SetEventObject(this);
|
||||||
|
wxPostEvent(this, event);
|
||||||
|
});
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ private:
|
||||||
std::vector<MPanel*> m_user_list_machine_panel;
|
std::vector<MPanel*> m_user_list_machine_panel;
|
||||||
boost::thread* get_print_info_thread{ nullptr };
|
boost::thread* get_print_info_thread{ nullptr };
|
||||||
std::string m_print_info;
|
std::string m_print_info;
|
||||||
|
std::shared_ptr<int> m_token = std::make_shared<int>(0);
|
||||||
std::map<std::string, MachineObject*> m_bind_machine_list;
|
std::map<std::string, MachineObject*> m_bind_machine_list;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -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(m_trouble_shoot, 0, wxLEFT | wxRIGHT | wxEXPAND, FromDIP(40));
|
||||||
|
|
||||||
m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(8));
|
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();
|
m_sizer_body->Layout();
|
||||||
|
|
||||||
SetSizer(m_sizer_body);
|
SetSizer(m_sizer_body);
|
||||||
|
|
|
@ -429,19 +429,23 @@ void SelectMachinePopup::Popup(wxWindow *WXUNUSED(focus))
|
||||||
|
|
||||||
if (wxGetApp().is_user_login()) {
|
if (wxGetApp().is_user_login()) {
|
||||||
if (!get_print_info_thread) {
|
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();
|
NetworkAgent* agent = wxGetApp().getAgent();
|
||||||
unsigned int http_code;
|
unsigned int http_code;
|
||||||
std::string body;
|
std::string body;
|
||||||
int result = agent->get_user_print_info(&http_code, &body);
|
int result = agent->get_user_print_info(&http_code, &body);
|
||||||
if (result == 0) {
|
CallAfter([token, this, result, body]() {
|
||||||
m_print_info = body;
|
if (token.expired()) {return;}
|
||||||
} else {
|
if (result == 0) {
|
||||||
m_print_info = "";
|
m_print_info = body;
|
||||||
}
|
}
|
||||||
wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST);
|
else {
|
||||||
event.SetEventObject(this);
|
m_print_info = "";
|
||||||
wxPostEvent(this, event);
|
}
|
||||||
|
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();
|
NetworkAgent* m_agent = wxGetApp().getAgent();
|
||||||
if (m_agent && m_agent->is_user_login()) {
|
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();
|
NetworkAgent* agent = wxGetApp().getAgent();
|
||||||
unsigned int http_code;
|
unsigned int http_code;
|
||||||
std::string body;
|
std::string body;
|
||||||
int result = agent->get_user_print_info(&http_code, &body);
|
int result = agent->get_user_print_info(&http_code, &body);
|
||||||
if (result == 0) {
|
CallAfter([token, this, result, body] {
|
||||||
m_print_info = body;
|
if (token.expired()) {return;}
|
||||||
}
|
if (result == 0) {
|
||||||
else {
|
m_print_info = body;
|
||||||
m_print_info = "";
|
}
|
||||||
}
|
else {
|
||||||
wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST);
|
m_print_info = "";
|
||||||
event.SetEventObject(this);
|
}
|
||||||
wxPostEvent(this, event);
|
wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST);
|
||||||
|
event.SetEventObject(this);
|
||||||
|
wxPostEvent(this, event);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST);
|
wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST);
|
||||||
|
|
|
@ -215,7 +215,8 @@ private:
|
||||||
std::vector<MachinePanel*> m_user_list_machine_panel;
|
std::vector<MachinePanel*> m_user_list_machine_panel;
|
||||||
std::vector<MachinePanel*> m_other_list_machine_panel;
|
std::vector<MachinePanel*> m_other_list_machine_panel;
|
||||||
boost::thread* get_print_info_thread{ nullptr };
|
boost::thread* get_print_info_thread{ nullptr };
|
||||||
std::string m_print_info;
|
std::shared_ptr<int> m_token = std::make_shared<int>(0);
|
||||||
|
std::string m_print_info = "";
|
||||||
bool m_dismiss { false };
|
bool m_dismiss { false };
|
||||||
|
|
||||||
std::map<std::string, MachineObject*> m_bind_machine_list;
|
std::map<std::string, MachineObject*> m_bind_machine_list;
|
||||||
|
@ -304,6 +305,7 @@ private:
|
||||||
wxColour m_colour_bold_color{wxColour(38, 46, 48)};
|
wxColour m_colour_bold_color{wxColour(38, 46, 48)};
|
||||||
StateColor m_btn_bg_enable;
|
StateColor m_btn_bg_enable;
|
||||||
|
|
||||||
|
std::shared_ptr<int> m_token = std::make_shared<int>(0);
|
||||||
std::map<std::string, CheckBox *> m_checkbox_list;
|
std::map<std::string, CheckBox *> m_checkbox_list;
|
||||||
//std::map<std::string, bool> m_checkbox_state_list;
|
//std::map<std::string, bool> m_checkbox_state_list;
|
||||||
std::vector<wxString> m_bedtype_list;
|
std::vector<wxString> m_bedtype_list;
|
||||||
|
|
|
@ -824,20 +824,23 @@ void SendToPrinterDialog::update_user_machine_list()
|
||||||
{
|
{
|
||||||
NetworkAgent* m_agent = wxGetApp().getAgent();
|
NetworkAgent* m_agent = wxGetApp().getAgent();
|
||||||
if (m_agent && m_agent->is_user_login()) {
|
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();
|
NetworkAgent* agent = wxGetApp().getAgent();
|
||||||
unsigned int http_code;
|
unsigned int http_code;
|
||||||
std::string body;
|
std::string body;
|
||||||
int result = agent->get_user_print_info(&http_code, &body);
|
int result = agent->get_user_print_info(&http_code, &body);
|
||||||
if (result == 0) {
|
CallAfter([token, this, result, body] {
|
||||||
m_print_info = body;
|
if (token.expired()) {return;}
|
||||||
}
|
if (result == 0) {
|
||||||
else {
|
m_print_info = body;
|
||||||
m_print_info = "";
|
}
|
||||||
}
|
else {
|
||||||
wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST);
|
m_print_info = "";
|
||||||
event.SetEventObject(this);
|
}
|
||||||
wxPostEvent(this, event);
|
wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST);
|
||||||
|
event.SetEventObject(this);
|
||||||
|
wxPostEvent(this, event);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST);
|
wxCommandEvent event(EVT_UPDATE_USER_MACHINE_LIST);
|
||||||
|
|
|
@ -114,7 +114,7 @@ private:
|
||||||
wxTimer* m_refresh_timer{ nullptr };
|
wxTimer* m_refresh_timer{ nullptr };
|
||||||
std::shared_ptr<BBLStatusBarSend> m_status_bar;
|
std::shared_ptr<BBLStatusBarSend> m_status_bar;
|
||||||
wxScrolledWindow* m_sw_print_failed_info{nullptr};
|
wxScrolledWindow* m_sw_print_failed_info{nullptr};
|
||||||
|
std::shared_ptr<int> m_token = std::make_shared<int>(0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SendToPrinterDialog(Plater* plater = nullptr);
|
SendToPrinterDialog(Plater* plater = nullptr);
|
||||||
|
|
|
@ -2733,9 +2733,11 @@ void StatusPanel::update_basic_print_data(bool def)
|
||||||
void StatusPanel::update_model_info()
|
void StatusPanel::update_model_info()
|
||||||
{
|
{
|
||||||
auto get_subtask_fn = [this](BBLModelTask* subtask) {
|
auto get_subtask_fn = [this](BBLModelTask* subtask) {
|
||||||
if (obj && obj->subtask_id_ == subtask->task_id) {
|
CallAfter([this, subtask]() {
|
||||||
obj->set_modeltask(subtask);
|
if (obj && obj->subtask_id_ == subtask->task_id) {
|
||||||
}
|
obj->set_modeltask(subtask);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue