From afd34d74b80061fad0cd7cf369b59931ce1aede4 Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Tue, 25 Aug 2020 14:25:22 +0200 Subject: [PATCH] Fix QPromise snippets: use QScopePointer instead of QPointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I2b863e43eb227a80ded3422ca57bd5f5d4209858 Reviewed-by: Sona Kurazyan Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Jarek Kobus --- .../corelib/thread/qpromise/snippet_qpromise.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp b/tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp index 571078feba..2975afca0f 100644 --- a/tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp +++ b/tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include class snippet_QPromise @@ -79,7 +79,7 @@ void snippet_QPromise::basicExample() // of calls: first promise.reportStarted() then future.waitForFinished() promise.reportStarted(); // notifies QFuture that the computation is started - QPointer thread(QThread::create([] (QPromise promise) { + QScopedPointer thread(QThread::create([] (QPromise promise) { promise.addResult(42); promise.reportFinished(); // notifies QFuture that the computation is finished }, std::move(promise))); @@ -106,14 +106,14 @@ void snippet_QPromise::multithreadExample() //! [multithread_main] // here, QPromise is shared between threads via a smart pointer - QPointer threads[] = { - QPointer(QThread::create([] (auto sharedPromise) { + QScopedPointer threads[] = { + QScopedPointer(QThread::create([] (auto sharedPromise) { sharedPromise->addResult(0, 0); // adds value 0 by index 0 }, sharedPromise)), - QPointer(QThread::create([] (auto sharedPromise) { + QScopedPointer(QThread::create([] (auto sharedPromise) { sharedPromise->addResult(-1, 1); // adds value -1 by index 1 }, sharedPromise)), - QPointer(QThread::create([] (auto sharedPromise) { + QScopedPointer(QThread::create([] (auto sharedPromise) { sharedPromise->addResult(-2, 2); // adds value -2 by index 2 }, sharedPromise)), // ... @@ -147,7 +147,7 @@ void snippet_QPromise::suspendExample() promise.reportStarted(); // Start a computation thread that supports suspension and cancellation - QPointer thread(QThread::create([] (QPromise promise) { + QScopedPointer thread(QThread::create([] (QPromise promise) { for (int i = 0; i < 100; ++i) { promise.addResult(i); promise.suspendIfRequested(); // support suspension