diff --git a/src/slic3r/GUI/Jobs/ArrangeJob.hpp b/src/slic3r/GUI/Jobs/ArrangeJob.hpp index a5e10f11a..2744920da 100644 --- a/src/slic3r/GUI/Jobs/ArrangeJob.hpp +++ b/src/slic3r/GUI/Jobs/ArrangeJob.hpp @@ -35,7 +35,9 @@ protected: void prepare() override; void on_exception(const std::exception_ptr &) override; - + + void process() override; + public: ArrangeJob(std::shared_ptr pri, Plater *plater) : PlaterJob{std::move(pri), plater} @@ -46,8 +48,6 @@ public: return int(m_selected.size() + m_unprintable.size()); } - void process() override; - void finalize() override; }; diff --git a/src/slic3r/GUI/Jobs/FillBedJob.hpp b/src/slic3r/GUI/Jobs/FillBedJob.hpp index 07290d2f2..bf407656d 100644 --- a/src/slic3r/GUI/Jobs/FillBedJob.hpp +++ b/src/slic3r/GUI/Jobs/FillBedJob.hpp @@ -24,6 +24,7 @@ class FillBedJob : public PlaterJob protected: void prepare() override; + void process() override; public: FillBedJob(std::shared_ptr pri, Plater *plater) @@ -35,8 +36,6 @@ public: return m_status_range; } - void process() override; - void finalize() override; }; diff --git a/src/slic3r/GUI/Jobs/Job.hpp b/src/slic3r/GUI/Jobs/Job.hpp index 082e5f4e8..8243ce943 100644 --- a/src/slic3r/GUI/Jobs/Job.hpp +++ b/src/slic3r/GUI/Jobs/Job.hpp @@ -49,11 +49,20 @@ protected: // Launched just before start(), a job can use it to prepare internals 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. 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: Job(std::shared_ptr pri); @@ -65,8 +74,6 @@ public: Job &operator=(const Job &) = delete; Job &operator=(Job &&) = delete; - virtual void process() = 0; - void start(); // To wait for the running job and join the threads. False is diff --git a/src/slic3r/GUI/Jobs/RotoptimizeJob.hpp b/src/slic3r/GUI/Jobs/RotoptimizeJob.hpp index 811c9c97e..cdb367f23 100644 --- a/src/slic3r/GUI/Jobs/RotoptimizeJob.hpp +++ b/src/slic3r/GUI/Jobs/RotoptimizeJob.hpp @@ -48,14 +48,14 @@ class RotoptimizeJob : public PlaterJob protected: void prepare() override; + void process() override; public: RotoptimizeJob(std::shared_ptr pri, Plater *plater) : PlaterJob{std::move(pri), plater} {} - - void process() override; + void finalize() override; static constexpr size_t get_methods_count() { return std::size(Methods); } diff --git a/src/slic3r/GUI/Jobs/SLAImportJob.hpp b/src/slic3r/GUI/Jobs/SLAImportJob.hpp index 543f42006..583c98655 100644 --- a/src/slic3r/GUI/Jobs/SLAImportJob.hpp +++ b/src/slic3r/GUI/Jobs/SLAImportJob.hpp @@ -10,18 +10,16 @@ class SLAImportJob : public PlaterJob { std::unique_ptr p; +protected: + void prepare() override; + void process() override; + void finalize() override; + public: SLAImportJob(std::shared_ptr pri, Plater *plater); ~SLAImportJob(); - void process() override; - void reset(); - -protected: - void prepare() override; - - void finalize() override; }; }} // namespace Slic3r::GUI