diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2022-01-18 13:07:43 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-21 03:05:51 +0000 |
commit | 5ce744e0857bec903924325489460730a5e2c93d (patch) | |
tree | 0eac69bf5106a2068ef1f77ca0ed31f87daa4f8e /tests | |
parent | d9c417ee98e3df3473acb7dbe8567d21a866b867 (diff) |
Use QPromise when creating continuations to avoid memory leaks
Continuations were using QFutureInterface to create and return the
associated future to the user. Attaching a continuation to the returned
future could cause memory leaks (described in an earlier commit). Use a
QPromise when saving the continuation, to make sure that the attached
continuation is cleaned in the destructor of the associated QPromise, so
that it doesn't keep any ref-counted copies to the shared data, thus
preventing it from being deleted.
Task-number: QTBUG-99534
Change-Id: I52d5501292095d41d1e060b7dd140c8e5d01335c
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 614847eae99bd4b6ce375f9f5572acfb3b513307)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/benchmarks/corelib/thread/qfuture/tst_bench_qfuture.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/tests/benchmarks/corelib/thread/qfuture/tst_bench_qfuture.cpp b/tests/benchmarks/corelib/thread/qfuture/tst_bench_qfuture.cpp index 17c2f20712..686bb76bdb 100644 --- a/tests/benchmarks/corelib/thread/qfuture/tst_bench_qfuture.cpp +++ b/tests/benchmarks/corelib/thread/qfuture/tst_bench_qfuture.cpp @@ -30,6 +30,7 @@ #include <qexception.h> #include <qfuture.h> +#include <qpromise.h> #include <qsemaphore.h> class tst_QFuture : public QObject |