mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-19 08:52:09 +00:00
ENH:add protection in threads
jira:[for random crash] Change-Id: I6286012dd77abccba461f7cd72a6fc531a84c95f
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user