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 <ivan.solovev@qt.io>
(cherry picked from commit 5c3dc2ecb97b69eb12e06c499ddb50666be60be6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2024-11-07 09:19:35 +01:00 committed by Qt Cherry-pick Bot
parent 2c1a23f3c8
commit f47c8354b1

View File

@ -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();