diff --git a/src/app/commands/cmd_change_pixel_format.cpp b/src/app/commands/cmd_change_pixel_format.cpp index 758a10189..ba3a9f01b 100644 --- a/src/app/commands/cmd_change_pixel_format.cpp +++ b/src/app/commands/cmd_change_pixel_format.cpp @@ -485,8 +485,8 @@ void ChangePixelFormatCommand::onExecute(Context* context) return; { - RenderTaskJob job( - "Converting Color Mode", + RenderTaskJob job("Converting Color Mode"); + job.startJob( [this, &job, context, flatten]{ ContextWriter writer(context); Transaction transaction(writer.context(), "Color Mode Change"); @@ -503,7 +503,6 @@ void ChangePixelFormatCommand::onExecute(Context* context) if (!job.isCanceled()) transaction.commit(); }); - job.startJob(); job.waitJob(); } diff --git a/src/app/commands/cmd_color_quantization.cpp b/src/app/commands/cmd_color_quantization.cpp index 22dc76011..aab5bbdd3 100644 --- a/src/app/commands/cmd_color_quantization.cpp +++ b/src/app/commands/cmd_color_quantization.cpp @@ -114,14 +114,13 @@ void ColorQuantizationCommand::onExecute(Context* context) Palette tmpPalette(frame, entries.picks()); - RenderTaskJob job( - "Creating Palette", + RenderTaskJob job("Creating Palette"); + job.startJob( [sprite, withAlpha, &tmpPalette, &job]{ render::create_palette_from_sprite( sprite, 0, sprite->lastFrame(), withAlpha, &tmpPalette, &job); }); - job.startJob(); job.waitJob(); if (job.isCanceled()) return; diff --git a/src/app/render_task_job.h b/src/app/render_task_job.h index 9a373ad3a..5c2b2c395 100644 --- a/src/app/render_task_job.h +++ b/src/app/render_task_job.h @@ -18,10 +18,14 @@ namespace app { class RenderTaskJob : public Job, public render::TaskDelegate { public: + RenderTaskJob(const char* jobName) + : Job(jobName) { + } + template - RenderTaskJob(const char* jobName, T&& func) - : Job(jobName) - , m_func(std::move(func)) { + void startJob(T&& func) { + m_func = std::move(func); + Job::startJob(); } private: