Do QFutureWatcher::setFuture() after connecting to watcher's signals

Otherwise we may have race condition.
Reference: documentation for QFutureWatcher::setFuture()
and the implementation of
QFutureInterfaceBasePrivate::connectOutputInterface(
QFutureCallOutInterface *interface).

Change-Id: I5b483baaf1b844871a162f47ce7683e9ff495acb
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2021-05-12 16:55:32 +02:00
parent 91f136ef3a
commit da27ac457f
7 changed files with 9 additions and 8 deletions

View File

@@ -75,9 +75,9 @@ void SimulatorOperationDialog::addFutures(const QList<QFuture<void> > &futureLis
foreach (auto future, futureList) {
if (!future.isFinished() || !future.isCanceled()) {
auto watcher = new QFutureWatcher<void>;
watcher->setFuture(future);
connect(watcher, &QFutureWatcher<void>::finished,
this, &SimulatorOperationDialog::futureFinished);
watcher->setFuture(future);
m_futureWatchList << watcher;
}
}