mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2026-02-23 04:45:04 -07:00
ENH:add protection in threads
jira:[for random crash] Change-Id: I6286012dd77abccba461f7cd72a6fc531a84c95f
This commit is contained in:
parent
eb9cc0c9e5
commit
eaa7abf518
8 changed files with 66 additions and 46 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue