diff --git a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp index e51594cfda3..8de956f094d 100644 --- a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp +++ b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp @@ -374,11 +374,13 @@ void tst_QPromise::addInThread() promise.start(); auto f = promise.future(); // move construct QPromise - ThreadWrapper thr([p = std::move(promise), &result] () mutable { + ThreadWrapper thr([&] { + auto p = std::move(promise); p.addResult(result); }); // Waits for result first - QCOMPARE(f.result(), result); + const auto actual = f.result(); + QCOMPARE(actual, result); QCOMPARE(f.resultAt(0), result); }; @@ -396,7 +398,8 @@ void tst_QPromise::addInThreadMoveOnlyObject() promise.start(); auto f = promise.future(); - ThreadWrapper thr([p = std::move(promise)] () mutable { + ThreadWrapper thr([&] { + auto p = std::move(promise); p.addResult(MoveOnlyType{-11}); }); @@ -473,7 +476,7 @@ void tst_QPromise::doNotCancelWhenFinished() promise.start(); // Finish QPromise inside thread, destructor must not call cancel() - ThreadWrapper([p = std::move(promise)] () mutable { p.finish(); }).join(); + ThreadWrapper([&] { auto p = std::move(promise); p.finish(); }).join(); f.waitForFinished(); @@ -533,7 +536,8 @@ void tst_QPromise::cancelWhenReassigned() auto f = promise.future(); promise.start(); - ThreadWrapper thr([p = std::move(promise)] () mutable { + ThreadWrapper thr([&] { + auto p = std::move(promise); QThread::sleep(100ms); p = QPromise(); // assign new promise, old must be correctly destroyed });