summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2022-01-18 13:07:43 +0100
committerSona Kurazyan <sona.kurazyan@qt.io>2022-01-21 01:51:20 +0100
commit614847eae99bd4b6ce375f9f5572acfb3b513307 (patch)
treec32138e946654043eb47662a5140db62ab960b15 /tests
parenta8794503ebdefec53a7a42479c477d04f0efa067 (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 Pick-to: 6.3 6.2 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>
Diffstat (limited to 'tests')
-rw-r--r--tests/benchmarks/corelib/thread/qfuture/tst_bench_qfuture.cpp1
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