summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp')
-rw-r--r--tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp
index 139eb6e..116f46e 100644
--- a/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp
+++ b/tests/auto/qtconcurrentmap/tst_qtconcurrentmap.cpp
@@ -74,6 +74,7 @@ private slots:
void incrementalResults();
void noDetatch();
void stlContainers();
+ void qFutureAssignmentLeak();
void stressTest();
public slots:
void throttling();
@@ -2323,6 +2324,36 @@ void tst_map::stlContainers()
#endif
}
+InstanceCounter ic_fn(const InstanceCounter & ic)
+{
+ return InstanceCounter(ic);
+};
+
+// Verify that held results are deleted when a future is
+// assigned over with operator ==
+void tst_map::qFutureAssignmentLeak()
+{
+ currentInstanceCount = 0;
+ peakInstanceCount = 0;
+ QFuture<InstanceCounter> future;
+ {
+ QList<InstanceCounter> list;
+ for (int i=0;i<1000;++i)
+ list += InstanceCounter();
+ future = QtConcurrent::mapped(list, ic_fn);
+ future.waitForFinished();
+
+ future = QtConcurrent::mapped(list, ic_fn);
+ future.waitForFinished();
+
+ future = QtConcurrent::mapped(list, ic_fn);
+ future.waitForFinished();
+ }
+
+ QCOMPARE(int(currentInstanceCount), 1000);
+ future = QFuture<InstanceCounter>();
+ QCOMPARE(int(currentInstanceCount), 0);
+}
inline void increment(int &num)
{