From f47c8354b114447103d7d733aa897fc6238563a5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 7 Nov 2024 09:19:35 +0100 Subject: [PATCH] tst_QPromise: don't rely on move-only lambdas [2/2] For some reason, 4d6cf54664a98e01d4caab42431c62d6deb9f86e didn't treat all lambdas, and no-one noticed. This patch completes the task by transforming the remaining lambdas to be non-move-only. Amends 4d6cf54664a98e01d4caab42431c62d6deb9f86e, whose commit message is pertinent to this patch, too, but not repeated here. Pick-to: 6.5 6.2 Change-Id: I6dfe6eb438065e16fcb7ab1f2efcb64c0146bb6c Reviewed-by: Ivan Solovev (cherry picked from commit 5c3dc2ecb97b69eb12e06c499ddb50666be60be6) Reviewed-by: Qt Cherry-pick Bot --- tests/auto/corelib/thread/qpromise/tst_qpromise.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp index 65ad0531f50..15e51a357d4 100644 --- a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp +++ b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp @@ -693,7 +693,9 @@ void testCancelWhenMoved() promise2.start(); // Move promises to local scope to test cancellation behavior - ThreadWrapper thr([p1 = std::move(promise1), p2 = std::move(promise2)] () mutable { + ThreadWrapper thr([&] { + auto p1 = std::move(promise1); + auto p2 = std::move(promise2); QThread::sleep(100ms); p1 = std::move(p2); p1.finish(); // this finish is for future #2 @@ -730,7 +732,8 @@ void tst_QPromise::waitUntilResumed() auto f = promise.future(); f.suspend(); - ThreadWrapper thr([p = std::move(promise)] () mutable { + ThreadWrapper thr([&] { + auto p = std::move(promise); p.suspendIfRequested(); p.addResult(42); // result added after suspend p.finish(); @@ -757,7 +760,8 @@ void tst_QPromise::waitUntilCanceled() auto f = promise.future(); f.suspend(); - ThreadWrapper thr([p = std::move(promise)] () mutable { + ThreadWrapper thr([&] { + auto p = std::move(promise); p.suspendIfRequested(); p.addResult(42); // result not added due to QFuture::cancel() p.finish();