Merge pull request #2630

3ea329e FutureScheduler: fix possible race, connect before setFuture (xiphon)
This commit is contained in:
luigi1111 2019-12-19 19:48:10 -05:00
commit 3984f8d1e8
No known key found for this signature in database
GPG key ID: F4ACA0183641E010

View file

@ -50,10 +50,10 @@ private:
try try
{ {
auto *watcher = newWatcher<T>(); auto *watcher = newWatcher<T>();
watcher->setFuture(makeFuture(watcher));
connect(watcher, &QFutureWatcher<T>::finished, [this, watcher] { connect(watcher, &QFutureWatcher<T>::finished, [this, watcher] {
watcher->deleteLater(); watcher->deleteLater();
}); });
watcher->setFuture(makeFuture(watcher));
return qMakePair(true, watcher->future()); return qMakePair(true, watcher->future());
} }
catch (const std::exception &exception) catch (const std::exception &exception)