diff --git a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp index ad7bcea60b3..65ad0531f50 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); }; @@ -395,7 +397,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}); }); @@ -469,7 +472,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(); @@ -527,7 +530,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 });