FIX: fix crash in update_slice_info

join update_slice_info thread when destroy
the MachineObject

Change-Id: I9f22cf5445ef9426651a8affa799da03b7456015
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2022-08-04 14:05:26 +08:00 committed by Lane.Wei
parent 36be714ed4
commit ed36024efa
2 changed files with 10 additions and 1 deletions

View file

@ -361,6 +361,13 @@ MachineObject::~MachineObject()
subtask_ = nullptr;
}
if (get_slice_info_thread) {
if (get_slice_info_thread->joinable()) {
get_slice_info_thread->join();
get_slice_info_thread = nullptr;
}
}
if (slice_info) {
delete slice_info;
slice_info = nullptr;
@ -2474,7 +2481,7 @@ void MachineObject::update_slice_info(std::string project_id, std::string profil
BOOST_LOG_TRIVIAL(trace) << "slice_info: start";
slice_info = new BBLSliceInfo();
auto get_slice_info_thread = boost::thread([this, project_id, profile_id, subtask_id, plate_idx] {
get_slice_info_thread = new boost::thread([this, project_id, profile_id, subtask_id, plate_idx] {
int plate_index = -1;
if (!m_agent) return;