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:
parent
0fcc235e14
commit
a7ec66c294
|
@ -317,6 +317,8 @@ void BackgroundSlicingProcess::thread_proc()
|
||||||
break;
|
break;
|
||||||
// Process the background slicing task.
|
// Process the background slicing task.
|
||||||
m_state = STATE_RUNNING;
|
m_state = STATE_RUNNING;
|
||||||
|
//BBS: internal cancel
|
||||||
|
m_internal_cancelled = false;
|
||||||
lck.unlock();
|
lck.unlock();
|
||||||
std::exception_ptr exception;
|
std::exception_ptr exception;
|
||||||
#ifdef _WIN32
|
#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();
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": send SlicingProcessCompletedEvent to main, status %1%")%evt.status();
|
||||||
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, evt.Clone());
|
wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, evt.Clone());
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
//BBS: internal cancel
|
||||||
|
m_internal_cancelled = true;
|
||||||
|
}
|
||||||
m_print->restart();
|
m_print->restart();
|
||||||
lck.unlock();
|
lck.unlock();
|
||||||
// Let the UI thread wake up if it is waiting for the background task to finish.
|
// Let the UI thread wake up if it is waiting for the background task to finish.
|
||||||
|
|
|
@ -184,6 +184,7 @@ public:
|
||||||
//BBS: improve the finished logic, also judge the m_gcode_result
|
//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(); }
|
||||||
bool finished() const { return m_print->finished() && !m_gcode_result->moves.empty(); }
|
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
|
//BBS: add Plater to friend class
|
||||||
//need to call stop_internal in ui thread
|
//need to call stop_internal in ui thread
|
||||||
|
@ -274,6 +275,7 @@ private:
|
||||||
//BBS: partplate related
|
//BBS: partplate related
|
||||||
GUI::PartPlate* m_current_plate;
|
GUI::PartPlate* m_current_plate;
|
||||||
PrinterTechnology m_printer_tech = ptUnknown;
|
PrinterTechnology m_printer_tech = ptUnknown;
|
||||||
|
bool m_internal_cancelled = false;
|
||||||
|
|
||||||
PrintState<BackgroundSlicingProcessStep, bspsCount> m_step_state;
|
PrintState<BackgroundSlicingProcessStep, bspsCount> m_step_state;
|
||||||
bool set_step_started(BackgroundSlicingProcessStep step);
|
bool set_step_started(BackgroundSlicingProcessStep step);
|
||||||
|
|
|
@ -4536,14 +4536,18 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
||||||
process_completed_with_error = -1;
|
process_completed_with_error = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (invalidated != Print::APPLY_STATUS_UNCHANGED && was_running && ! this->background_process.running() &&
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", Line %1%: was_running = %2%, running %3%, invalidated=%4%, return_state=%5%, internal_cancel=%6%")
|
||||||
(return_state & UPDATE_BACKGROUND_PROCESS_RESTART) == 0) {
|
% __LINE__ % was_running % this->background_process.running() % invalidated % return_state % this->background_process.is_internal_cancelled();
|
||||||
// The background processing was killed and it will not be restarted.
|
if (was_running && ! this->background_process.running() && (return_state & UPDATE_BACKGROUND_PROCESS_RESTART) == 0) {
|
||||||
// Post the "canceled" callback message, so that it will be processed after any possible pending status bar update messages.
|
if (invalidated != Print::APPLY_STATUS_UNCHANGED || this->background_process.is_internal_cancelled())
|
||||||
SlicingProcessCompletedEvent evt(EVT_PROCESS_COMPLETED, 0,
|
{
|
||||||
SlicingProcessCompletedEvent::Cancelled, nullptr);
|
// The background processing was killed and it will not be restarted.
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%, post an EVT_PROCESS_COMPLETED to main, status %2%")%__LINE__ %evt.status();
|
// Post the "canceled" callback message, so that it will be processed after any possible pending status bar update messages.
|
||||||
wxQueueEvent(q, evt.Clone());
|
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)
|
if ((return_state & UPDATE_BACKGROUND_PROCESS_INVALID) != 0)
|
||||||
|
|
Loading…
Reference in New Issue