From 9d0a8497f9693bccdd1c031104ea5837dc62e4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Fri, 3 Apr 2015 16:34:05 +0200 Subject: Async: fix crash in Job::nestedJobWrapper --- async/src/async.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'async/src') diff --git a/async/src/async.h b/async/src/async.h index c6ca9e7..7425604 100644 --- a/async/src/async.h +++ b/async/src/async.h @@ -499,9 +499,14 @@ private: auto job = otherJob; FutureWatcher *watcher = new FutureWatcher(); QObject::connect(watcher, &FutureWatcherBase::futureReady, - [watcher, &future]() { - Async::detail::copyFutureValue(watcher->future(), future); - future.setFinished(); + [watcher, future]() { + // FIXME: We pass future by value, because using reference causes the + // future to get deleted before this lambda is invoked, leading to crash + // in copyFutureValue() + // copy by value is const + auto outFuture = future; + Async::detail::copyFutureValue(watcher->future(), outFuture); + outFuture.setFinished(); delete watcher; }); watcher->setFuture(job.exec(in ...)); -- cgit v1.2.3