FIX: fix a slicing state not correct issue in some corner case[Studio-2600]

add a new object in other plate when slicing a plate
it will stop the background slicing process
and it should also send a complete event

Change-Id: Ie7cbcb5a97251a002b7448eb8a9c5bbde1680956
(cherry picked from commit 710a2b273424d59313d7053f0f2c2b54b0c849c0)
This commit is contained in:
lane.wei 2023-06-16 09:25:51 +08:00 committed by Lane.Wei
parent 0fcc235e14
commit a7ec66c294
3 changed files with 20 additions and 8 deletions

View File

@ -317,6 +317,8 @@ void BackgroundSlicingProcess::thread_proc()
break;
// Process the background slicing task.
m_state = STATE_RUNNING;
//BBS: internal cancel
m_internal_cancelled = false;
lck.unlock();
std::exception_ptr exception;
#ifdef _WIN32
@ -337,6 +339,10 @@ void BackgroundSlicingProcess::thread_proc()
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": send SlicingProcessCompletedEvent to main, status %1%")%evt.status();
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, evt.Clone());
}
else {
//BBS: internal cancel
m_internal_cancelled = true;
}
m_print->restart();
lck.unlock();
// Let the UI thread wake up if it is waiting for the background task to finish.

View File

@ -184,6 +184,7 @@ public:
//BBS: improve the finished logic, also judge the m_gcode_result
//bool finished() const { return m_print->finished(); }
bool finished() const { return m_print->finished() && !m_gcode_result->moves.empty(); }
bool is_internal_cancelled() { return m_internal_cancelled; }
//BBS: add Plater to friend class
//need to call stop_internal in ui thread
@ -274,6 +275,7 @@ private:
//BBS: partplate related
GUI::PartPlate* m_current_plate;
PrinterTechnology m_printer_tech = ptUnknown;
bool m_internal_cancelled = false;
PrintState<BackgroundSlicingProcessStep, bspsCount> m_step_state;
bool set_step_started(BackgroundSlicingProcessStep step);

View File

@ -4536,14 +4536,18 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
process_completed_with_error = -1;
}
if (invalidated != Print::APPLY_STATUS_UNCHANGED && was_running && ! this->background_process.running() &&
(return_state & UPDATE_BACKGROUND_PROCESS_RESTART) == 0) {
// The background processing was killed and it will not be restarted.
// Post the "canceled" callback message, so that it will be processed after any possible pending status bar update messages.
SlicingProcessCompletedEvent evt(EVT_PROCESS_COMPLETED, 0,
SlicingProcessCompletedEvent::Cancelled, nullptr);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%, post an EVT_PROCESS_COMPLETED to main, status %2%")%__LINE__ %evt.status();
wxQueueEvent(q, evt.Clone());
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", Line %1%: was_running = %2%, running %3%, invalidated=%4%, return_state=%5%, internal_cancel=%6%")
% __LINE__ % was_running % this->background_process.running() % invalidated % return_state % this->background_process.is_internal_cancelled();
if (was_running && ! this->background_process.running() && (return_state & UPDATE_BACKGROUND_PROCESS_RESTART) == 0) {
if (invalidated != Print::APPLY_STATUS_UNCHANGED || this->background_process.is_internal_cancelled())
{
// The background processing was killed and it will not be restarted.
// Post the "canceled" callback message, so that it will be processed after any possible pending status bar update messages.
SlicingProcessCompletedEvent evt(EVT_PROCESS_COMPLETED, 0,
SlicingProcessCompletedEvent::Cancelled, nullptr);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%, post an EVT_PROCESS_COMPLETED to main, status %2%")%__LINE__ %evt.status();
wxQueueEvent(q, evt.Clone());
}
}
if ((return_state & UPDATE_BACKGROUND_PROCESS_INVALID) != 0)