aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlpropertycache
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-01-02 14:41:38 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-01-02 15:46:49 +0100
commit895eb11574d19fa50e734374fd2d85365e023c5e (patch)
tree88e5972f4f2a74dfe3d9bb8fcb6c11d59bafc390 /tests/auto/qml/qqmlpropertycache
parentbe48640d80fd5939d9d38836a648a0c43d8671bd (diff)
tst_qqmlpropertycache: Avoid memory leaks
All the property caches come with one initial ref. The QQmlRefPointers need to adopt that one. Change-Id: I27ae2226c39888e2e5d99f593c2857456c048f2c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlpropertycache')
-rw-r--r--tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
index c9e92cd3c9..2237489663 100644
--- a/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
+++ b/tests/auto/qml/qqmlpropertycache/tst_qqmlpropertycache.cpp
@@ -114,7 +114,8 @@ void tst_qqmlpropertycache::properties()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
- QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(metaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(metaObject),
+ QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyData *data;
QVERIFY((data = cacheProperty(cache, "propertyA")));
@@ -136,8 +137,11 @@ void tst_qqmlpropertycache::propertiesDerived()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
- QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&BaseObject::staticMetaObject));
- QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject()));
+ QQmlRefPointer<QQmlPropertyCache> parentCache(
+ new QQmlPropertyCache(&BaseObject::staticMetaObject),
+ QQmlRefPointer<QQmlPropertyCache>::Adopt);
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject()),
+ QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyData *data;
QVERIFY((data = cacheProperty(cache, "propertyA")));
@@ -161,8 +165,10 @@ void tst_qqmlpropertycache::revisionedProperties()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
- QQmlRefPointer<QQmlPropertyCache> cacheWithoutVersion(new QQmlPropertyCache(metaObject));
- QQmlRefPointer<QQmlPropertyCache> cacheWithVersion(new QQmlPropertyCache(metaObject, 1));
+ QQmlRefPointer<QQmlPropertyCache> cacheWithoutVersion(new QQmlPropertyCache(metaObject),
+ QQmlRefPointer<QQmlPropertyCache>::Adopt);
+ QQmlRefPointer<QQmlPropertyCache> cacheWithVersion(new QQmlPropertyCache(metaObject, 1),
+ QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyData *data;
QVERIFY((data = cacheProperty(cacheWithoutVersion, "propertyE")));
@@ -176,7 +182,8 @@ void tst_qqmlpropertycache::methods()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
- QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(metaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(metaObject),
+ QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyData *data;
QVERIFY((data = cacheProperty(cache, "slotA")));
@@ -210,8 +217,11 @@ void tst_qqmlpropertycache::methodsDerived()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
- QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&BaseObject::staticMetaObject));
- QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject()));
+ QQmlRefPointer<QQmlPropertyCache> parentCache(
+ new QQmlPropertyCache(&BaseObject::staticMetaObject),
+ QQmlRefPointer<QQmlPropertyCache>::Adopt);
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject()),
+ QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyData *data;
QVERIFY((data = cacheProperty(cache, "slotA")));
@@ -245,7 +255,8 @@ void tst_qqmlpropertycache::signalHandlers()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
- QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(metaObject));
+ QQmlRefPointer<QQmlPropertyCache> cache(new QQmlPropertyCache(metaObject),
+ QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyData *data;
QVERIFY((data = cacheProperty(cache, "onSignalA")));
@@ -273,8 +284,11 @@ void tst_qqmlpropertycache::signalHandlersDerived()
DerivedObject object;
const QMetaObject *metaObject = object.metaObject();
- QQmlRefPointer<QQmlPropertyCache> parentCache(new QQmlPropertyCache(&BaseObject::staticMetaObject));
- QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject()));
+ QQmlRefPointer<QQmlPropertyCache> parentCache(
+ new QQmlPropertyCache(&BaseObject::staticMetaObject),
+ QQmlRefPointer<QQmlPropertyCache>::Adopt);
+ QQmlRefPointer<QQmlPropertyCache> cache(parentCache->copyAndAppend(object.metaObject()),
+ QQmlRefPointer<QQmlPropertyCache>::Adopt);
QQmlPropertyData *data;
QVERIFY((data = cacheProperty(cache, "onSignalA")));