FIX: dead blocking while cancel printing
jira: [STUDIO-10612] Change-Id: Id64264bc3c6c4fb8255999770504975be544a85f
This commit is contained in:
parent
40654323b0
commit
06a420bdf3
|
@ -47,6 +47,7 @@ GUI::Job::Job(std::shared_ptr<ProgressIndicator> pri)
|
|||
|
||||
Bind(wxEVT_THREAD, [this](const wxThreadEvent &evt) {
|
||||
if (m_finalizing) return;
|
||||
if (evt.GetInt() >= 100) { update_percent_finish(); }
|
||||
|
||||
auto msg = evt.GetString();
|
||||
if (!msg.empty() && !m_worker_error)
|
||||
|
|
|
@ -341,18 +341,18 @@ void PrintJob::process()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if (params.stl_design_id == 0 || !wxGetApp().model().design_id.empty()) {
|
||||
const auto& model_design_id = wxGetApp().model().design_id;
|
||||
if (params.stl_design_id == 0 || !model_design_id.empty()) {
|
||||
if (model_design_id.empty()) {
|
||||
params.stl_design_id = 0;
|
||||
} else {
|
||||
try {
|
||||
params.stl_design_id = std::stoi(wxGetApp().model().design_id);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
params.stl_design_id = std::stoi(model_design_id);
|
||||
} catch (...) {
|
||||
params.stl_design_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (params.preset_name.empty() && m_print_type == "from_normal") { params.preset_name = wxString::Format("%s_plate_%d", m_project_name, curr_plate_idx).ToStdString(); }
|
||||
if (params.project_name.empty()) {params.project_name = m_project_name;}
|
||||
|
@ -388,7 +388,7 @@ void PrintJob::process()
|
|||
&error_text,
|
||||
StagePercentPoint
|
||||
](int stage, int code, std::string info) {
|
||||
|
||||
m_print_stage = stage;
|
||||
if (stage == BBL::SendingPrintJobStage::PrintingStageCreate && !is_try_lan_mode_failed) {
|
||||
if (this->connection_type == "lan") {
|
||||
msg = _L("Sending print job over LAN");
|
||||
|
@ -428,7 +428,6 @@ void PrintJob::process()
|
|||
if (m_print_job_completed_id == wxGetApp().plater()->get_send_calibration_finished_event()) {
|
||||
msg = wxString::Format(_L("Successfully sent. Will automatically jump to the next page in %ss"), info);
|
||||
}
|
||||
this->update_percent_finish();
|
||||
} else {
|
||||
if (this->connection_type == "lan") {
|
||||
msg = _L("Sending print job over LAN");
|
||||
|
@ -504,6 +503,12 @@ void PrintJob::process()
|
|||
BOOST_LOG_TRIVIAL(info) << "print_job: printer has enter printing status, s = " << obj->print_status;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this->was_canceled()) {
|
||||
BOOST_LOG_TRIVIAL(info) << "print_job: user cancel the job" << obj->job_id_;
|
||||
return true;
|
||||
}
|
||||
|
||||
time_out++;
|
||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(1000));
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ class PrintJob : public PlaterJob
|
|||
std::string m_dev_id;
|
||||
bool m_job_finished{ false };
|
||||
int m_print_job_completed_id = 0;
|
||||
int m_print_stage = 0;
|
||||
wxString m_completed_evt_data;
|
||||
std::function<void()> m_enter_ip_address_fun_fail{ nullptr };
|
||||
std::function<void()> m_enter_ip_address_fun_success{ nullptr };
|
||||
|
@ -110,6 +111,8 @@ public:
|
|||
}
|
||||
|
||||
bool is_finished() { return m_job_finished; }
|
||||
int get_print_stage() const { return m_print_stage;}
|
||||
|
||||
void set_print_job_finished_event(int event_id, wxString evt_data = wxEmptyString) {
|
||||
m_print_job_completed_id = event_id;
|
||||
m_completed_evt_data = evt_data;
|
||||
|
|
|
@ -2747,6 +2747,11 @@ void SelectMachineDialog::on_set_finish_mapping(wxCommandEvent &evt)
|
|||
void SelectMachineDialog::on_print_job_cancel(wxCommandEvent &evt)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << "print_job: canceled";
|
||||
if (m_print_job->get_print_stage() == PrintingStageFinished)
|
||||
{
|
||||
MessageDialog dlg(this, _L("As the print job has been successfully sent, the cancellation will not bring the print job to a halt. If you need to terminate this job, please stop it in 'Device' page."), _L("Info"), wxYES);
|
||||
dlg.ShowModal();
|
||||
}
|
||||
|
||||
EnableEditing(true);
|
||||
show_status(PrintDialogStatus::PrintStatusInit);
|
||||
|
|
Loading…
Reference in New Issue