Fix RenderTaskJob compilation on MSVC

We cannot refer the "job" instance in the lambda captures on the same
statement on MSVC compiler.
This commit is contained in:
David Capello 2017-05-26 11:30:58 -03:00
parent 239ac42378
commit 93d59f87e9
3 changed files with 11 additions and 9 deletions

View File

@ -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();
}

View File

@ -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;

View File

@ -18,10 +18,14 @@ namespace app {
class RenderTaskJob : public Job,
public render::TaskDelegate {
public:
RenderTaskJob(const char* jobName)
: Job(jobName) {
}
template<typename T>
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: