FIX: update while it's print job
jira: [STUDIO-10848] Change-Id: I19c96dce7d48d46bdf4ed7861ab2136644195e34
This commit is contained in:
parent
1abcd64e72
commit
6f527fd6aa
|
@ -47,7 +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(); }
|
||||
if (this->is_print_job() && evt.GetInt() >= 100) { update_percent_finish(); }
|
||||
|
||||
auto msg = evt.GetString();
|
||||
if (!msg.empty() && !m_worker_error)
|
||||
|
|
|
@ -35,13 +35,13 @@ class Job : public wxEvtHandler
|
|||
bool m_finalized = false, m_finalizing = false;
|
||||
std::shared_ptr<ProgressIndicator> m_progress;
|
||||
std::exception_ptr m_worker_error = nullptr;
|
||||
|
||||
|
||||
void run(std::exception_ptr &);
|
||||
|
||||
|
||||
protected:
|
||||
// status range for a particular job
|
||||
virtual int status_range() const { return 100; }
|
||||
|
||||
|
||||
// status update, to be used from the work thread (process() method)
|
||||
void update_status(int st, const wxString &msg = "");
|
||||
|
||||
|
@ -56,7 +56,7 @@ protected:
|
|||
|
||||
// The method where the actual work of the job should be defined.
|
||||
virtual void process() = 0;
|
||||
|
||||
|
||||
// Launched when the job is finished. It refreshes the 3Dscene by def.
|
||||
virtual void finalize() { m_finalized = true; }
|
||||
|
||||
|
@ -67,7 +67,7 @@ protected:
|
|||
{
|
||||
if (eptr) std::rethrow_exception(eptr);
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
enum JobPrepareState {
|
||||
PREPARE_STATE_DEFAULT = 0,
|
||||
|
@ -76,24 +76,28 @@ public:
|
|||
};
|
||||
|
||||
Job(std::shared_ptr<ProgressIndicator> pri);
|
||||
|
||||
|
||||
bool is_finalized() const { return m_finalized; }
|
||||
|
||||
|
||||
Job(const Job &) = delete;
|
||||
Job(Job &&) = delete;
|
||||
Job &operator=(const Job &) = delete;
|
||||
Job &operator=(Job &&) = delete;
|
||||
|
||||
|
||||
void start();
|
||||
|
||||
|
||||
// To wait for the running job and join the threads. False is
|
||||
// returned if the timeout has been reached and the job is still
|
||||
// running. Call cancel() before this fn if you want to explicitly
|
||||
// end the job.
|
||||
bool join(int timeout_ms = 0);
|
||||
|
||||
|
||||
bool is_running() const { return m_running.load(); }
|
||||
void cancel() { m_canceled.store(true); }
|
||||
|
||||
public:
|
||||
/*type check*/
|
||||
virtual bool is_print_job() const { return false; }
|
||||
};
|
||||
|
||||
// Jobs defined inside the group class will be managed so that only one can
|
||||
|
@ -102,29 +106,29 @@ public:
|
|||
class ExclusiveJobGroup
|
||||
{
|
||||
static const int ABORT_WAIT_MAX_MS = 10000;
|
||||
|
||||
|
||||
std::vector<std::unique_ptr<GUI::Job>> m_jobs;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void before_start() {}
|
||||
|
||||
|
||||
public:
|
||||
virtual ~ExclusiveJobGroup() = default;
|
||||
|
||||
|
||||
size_t add_job(std::unique_ptr<GUI::Job> &&job)
|
||||
{
|
||||
m_jobs.emplace_back(std::move(job));
|
||||
return m_jobs.size() - 1;
|
||||
}
|
||||
|
||||
|
||||
void start(size_t jid);
|
||||
|
||||
|
||||
void cancel_all() { for (auto& j : m_jobs) j->cancel(); }
|
||||
|
||||
|
||||
void join_all(int wait_ms = 0);
|
||||
|
||||
|
||||
void stop_all() { cancel_all(); join_all(ABORT_WAIT_MAX_MS); }
|
||||
|
||||
|
||||
bool is_any_running() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ protected:
|
|||
void on_exception(const std::exception_ptr &) override;
|
||||
public:
|
||||
PrintJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater, std::string dev_id = "");
|
||||
virtual bool is_print_job() const override { return true; }
|
||||
|
||||
std::string m_project_name;
|
||||
std::string m_dev_ip;
|
||||
|
|
Loading…
Reference in New Issue