diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2020-08-25 14:25:22 +0200 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2020-08-26 01:12:50 +0200 |
commit | afd34d74b80061fad0cd7cf369b59931ce1aede4 (patch) | |
tree | a499c15e1596cb73c8ed17427e776cd5d05e2731 /tests | |
parent | 967f2fbfad2907a00d1d6ac6ca5e0821505331b1 (diff) |
Fix QPromise snippets: use QScopePointer instead of QPointer
Change-Id: I2b863e43eb227a80ded3422ca57bd5f5d4209858
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/thread/qpromise/snippet_qpromise.cpp | 14 |
1 files 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 <qfuture.h> #include <qfuturewatcher.h> #include <qpromise.h> -#include <qpointer.h> +#include <qscopedpointer.h> #include <qsharedpointer.h> 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<QThread> thread(QThread::create([] (QPromise<int> promise) { + QScopedPointer<QThread> thread(QThread::create([] (QPromise<int> 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<QThread> threads[] = { - QPointer<QThread>(QThread::create([] (auto sharedPromise) { + QScopedPointer<QThread> threads[] = { + QScopedPointer<QThread>(QThread::create([] (auto sharedPromise) { sharedPromise->addResult(0, 0); // adds value 0 by index 0 }, sharedPromise)), - QPointer<QThread>(QThread::create([] (auto sharedPromise) { + QScopedPointer<QThread>(QThread::create([] (auto sharedPromise) { sharedPromise->addResult(-1, 1); // adds value -1 by index 1 }, sharedPromise)), - QPointer<QThread>(QThread::create([] (auto sharedPromise) { + QScopedPointer<QThread>(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<QThread> thread(QThread::create([] (QPromise<int> promise) { + QScopedPointer<QThread> thread(QThread::create([] (QPromise<int> promise) { for (int i = 0; i < 100; ++i) { promise.addResult(i); promise.suspendIfRequested(); // support suspension |