mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-09 18:27:00 +00:00
Parse user print info on the UI thread to prevent heap corruption (#119)
get_user_print_info()'s HTTP fetch can run on a worker thread (e.g. BindJob), but parse_user_print_info() mutates userMachineList (insert/erase/delete MachineObject). on_machine_alive (SSDP) mutates the same maps on the UI thread without locking, so parsing off-thread races the map and frees MachineObjects out from under it -> heap corruption. Keep all device-list mutation on the UI thread: parse inline when already on the main thread, otherwise marshal via CallAfter so it stays serialized with on_machine_alive.
This commit is contained in:
@@ -851,7 +851,9 @@ namespace Slic3r
|
|||||||
int result = m_agent->get_user_print_info(&http_code, &body, provider);
|
int result = m_agent->get_user_print_info(&http_code, &body, provider);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
parse_user_print_info(body);
|
// parse_user_print_info and on_machine_alive (SSDP for discovery) both mutate the same userMachineList map.
|
||||||
|
// on_machine_alive mutates the map on the UI thread, do the same for parse_user_print_info.
|
||||||
|
Slic3r::GUI::wxGetApp().CallAfter([this, body]() { parse_user_print_info(body); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user