aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlpropertymap
diff options
context:
space:
mode:
authorAmanda Hamblin-Trué <amanda.hamblin-true@qt.io>2023-08-15 14:35:39 +0200
committerAmanda Hamblin-Trué <amanda.hamblin-true@qt.io>2023-08-21 08:46:00 +0200
commitea5ffb7b412694d6f688daa4623e9a9c7fd8f9a1 (patch)
tree0e7f7fd8f1035dcb34ce3bca2d478e2027cec097 /tests/auto/qml/qqmlpropertymap
parent6925562c35f526a47ee66bbf732c6b822b424daa (diff)
tst_qqmlpropertymap: Clean up memory management
Task-number: QTBUG-115222 Change-Id: I23c43432b6b9e02ded694029a0290da038ece680 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlpropertymap')
-rw-r--r--tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp27
1 files changed, 9 insertions, 18 deletions
diff --git a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
index 689202346c..3b6e2c88b9 100644
--- a/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
+++ b/tests/auto/qml/qqmlpropertymap/tst_qqmlpropertymap.cpp
@@ -346,9 +346,8 @@ void tst_QQmlPropertyMap::controlledWrite()
component.setData(qmlSource, QUrl::fromLocalFile(""));
QVERIFY(component.isReady());
- QObject *obj = component.create();
- QVERIFY(obj);
- delete obj;
+ std::unique_ptr<QObject> obj { component.create() };
+ QVERIFY(obj.get());
QCOMPARE(map.value(QLatin1String("key1")), QVariant("HELLO WORLD"));
QCOMPARE(map.value(QLatin1String("key2")), QVariant("Goodbye"));
@@ -364,8 +363,7 @@ void tst_QQmlPropertyMap::crashBug()
QQmlComponent c(&engine);
c.setData("import QtQuick 2.0\nBinding { target: map; property: \"myProp\"; value: 10 + 23 }",QUrl());
- QObject *obj = c.create(&context);
- delete obj;
+ std::unique_ptr<QObject> obj { c.create(&context) };
}
void tst_QQmlPropertyMap::QTBUG_17868()
@@ -378,10 +376,9 @@ void tst_QQmlPropertyMap::QTBUG_17868()
map.insert("key", 1);
QQmlComponent c(&engine);
c.setData("import QtQuick 2.0\nItem {property bool error:false; Component.onCompleted: {try{ map.keys(); }catch(e) {error=true;}}}",QUrl());
- QObject *obj = c.create(&context);
- QVERIFY(obj);
+ std::unique_ptr<QObject> obj { c.create(&context) };
+ QVERIFY(obj.get());
QVERIFY(!obj->property("error").toBool());
- delete obj;
}
@@ -434,17 +431,14 @@ void tst_QQmlPropertyMap::QTBUG_31226()
" Timer { interval: 5; running: true; onTriggered: { myProp = qmlPropertyMap.greeting; } }\n"
"}",
QUrl());
- QObject *obj = c.create(&context);
- QVERIFY(obj);
+ std::unique_ptr<QObject> obj { c.create(&context) };
+ QVERIFY(obj.get());
QQmlPropertyMap *qmlPropertyMap = obj->findChild<QQmlPropertyMap*>(QString("qmlPropertyMap"));
QVERIFY(qmlPropertyMap);
qmlPropertyMap->insert("greeting", QString("Hello world!"));
QTRY_COMPARE(obj->property("myProp").toString(), QString("Hello world!"));
-
- delete obj;
-
}
void tst_QQmlPropertyMap::QTBUG_29836()
@@ -461,13 +455,10 @@ void tst_QQmlPropertyMap::QTBUG_29836()
" Timer { interval: 5; running: true; onTriggered: enhancedMap.testSlot() }\n"
"}",
QUrl());
- QObject *obj = c.create(&context);
- QVERIFY(obj);
+ std::unique_ptr<QObject> obj { c.create(&context) };
+ QVERIFY(obj.get());
QTRY_COMPARE(map.testSlotCalled(), true);
-
- delete obj;
-
}
void tst_QQmlPropertyMap::QTBUG_35233()