summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2024-11-07 09:19:35 +0100
committerMarc Mutz <marc.mutz@qt.io>2024-11-07 20:49:19 +0100
commit5c3dc2ecb97b69eb12e06c499ddb50666be60be6 (patch)
tree2c3827ff0b16fa0b9a6643e907c136d9a63b93d4
parent4c00337ccb8e4266fa5a4af4fba40e5b62aba81b (diff)
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.8 6.5 6.2 Change-Id: I6dfe6eb438065e16fcb7ab1f2efcb64c0146bb6c Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
-rw-r--r--tests/auto/corelib/thread/qpromise/tst_qpromise.cpp10
1 files 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 06198b0c9d3..61fc9c46a8e 100644
--- a/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
+++ b/tests/auto/corelib/thread/qpromise/tst_qpromise.cpp
@@ -775,7 +775,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
@@ -811,7 +813,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();
@@ -840,7 +843,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();