Change UI job's process() method to be protected, as it should have been

Also add some comments to the interface of Job class
This commit is contained in:
tamasmeszaros 2021-08-20 13:43:52 +02:00
parent 883f46662d
commit 6efea25478
5 changed files with 21 additions and 17 deletions

View File

@ -35,7 +35,9 @@ protected:
void prepare() override; void prepare() override;
void on_exception(const std::exception_ptr &) override; void on_exception(const std::exception_ptr &) override;
void process() override;
public: public:
ArrangeJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater) ArrangeJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
: PlaterJob{std::move(pri), plater} : PlaterJob{std::move(pri), plater}
@ -46,8 +48,6 @@ public:
return int(m_selected.size() + m_unprintable.size()); return int(m_selected.size() + m_unprintable.size());
} }
void process() override;
void finalize() override; void finalize() override;
}; };

View File

@ -24,6 +24,7 @@ class FillBedJob : public PlaterJob
protected: protected:
void prepare() override; void prepare() override;
void process() override;
public: public:
FillBedJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater) FillBedJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
@ -35,8 +36,6 @@ public:
return m_status_range; return m_status_range;
} }
void process() override;
void finalize() override; void finalize() override;
}; };

View File

@ -49,11 +49,20 @@ protected:
// Launched just before start(), a job can use it to prepare internals // Launched just before start(), a job can use it to prepare internals
virtual void prepare() {} virtual void prepare() {}
// 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. // Launched when the job is finished. It refreshes the 3Dscene by def.
virtual void finalize() { m_finalized = true; } virtual void finalize() { m_finalized = true; }
virtual void on_exception(const std::exception_ptr &) {} // Exceptions occuring in process() are redirected from the worker thread
// into the main (UI) thread. This method is called from the main thread and
// can be overriden to handle these exceptions.
virtual void on_exception(const std::exception_ptr &eptr)
{
if (eptr) std::rethrow_exception(eptr);
}
public: public:
Job(std::shared_ptr<ProgressIndicator> pri); Job(std::shared_ptr<ProgressIndicator> pri);
@ -65,8 +74,6 @@ public:
Job &operator=(const Job &) = delete; Job &operator=(const Job &) = delete;
Job &operator=(Job &&) = delete; Job &operator=(Job &&) = delete;
virtual void process() = 0;
void start(); void start();
// To wait for the running job and join the threads. False is // To wait for the running job and join the threads. False is

View File

@ -48,14 +48,14 @@ class RotoptimizeJob : public PlaterJob
protected: protected:
void prepare() override; void prepare() override;
void process() override;
public: public:
RotoptimizeJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater) RotoptimizeJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater)
: PlaterJob{std::move(pri), plater} : PlaterJob{std::move(pri), plater}
{} {}
void process() override;
void finalize() override; void finalize() override;
static constexpr size_t get_methods_count() { return std::size(Methods); } static constexpr size_t get_methods_count() { return std::size(Methods); }

View File

@ -10,18 +10,16 @@ class SLAImportJob : public PlaterJob {
std::unique_ptr<priv> p; std::unique_ptr<priv> p;
protected:
void prepare() override;
void process() override;
void finalize() override;
public: public:
SLAImportJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater); SLAImportJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater);
~SLAImportJob(); ~SLAImportJob();
void process() override;
void reset(); void reset();
protected:
void prepare() override;
void finalize() override;
}; };
}} // namespace Slic3r::GUI }} // namespace Slic3r::GUI