From c6e63aa128b0cbf5000a57154aadf9a2e2f081ab Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 19 Dec 2019 11:23:46 +0100 Subject: tst_qqmlmetatype.cpp: Avoid memory leaks Change-Id: Ic4ff36e48a1ff5146ec44f58ed416fd24cce5330 Reviewed-by: Fabian Kosmale --- tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'tests/auto/qml/qqmlmetatype') diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index 76185a97e0..72295044a5 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -307,7 +307,7 @@ void tst_qqmlmetatype::compositeType() //Loading the test file also loads all composite types it imports QQmlComponent c(&engine, testFileUrl("testImplicitComposite.qml")); - QObject* obj = c.create(); + QScopedPointer obj(c.create()); QVERIFY(obj); QQmlType type = QQmlMetaType::qmlType(QString("ImplicitType"), QString(""), 1, 0); @@ -324,7 +324,7 @@ void tst_qqmlmetatype::externalEnums() qmlRegisterSingletonType("x.y.z", 1, 0, "ExternalEnums", ExternalEnums::create); QQmlComponent c(&engine, testFileUrl("testExternalEnums.qml")); - QObject *obj = c.create(); + QScopedPointer obj(c.create()); QVERIFY(obj); QVariant a = obj->property("a"); QCOMPARE(a.type(), QVariant::Int); @@ -552,7 +552,8 @@ void tst_qqmlmetatype::unregisterAttachedProperties() QCOMPARE(attachedType.attachedPropertiesType(QQmlEnginePrivate::get(&e)), attachedType.metaObject()); - QVERIFY(c.create()); + QScopedPointer obj(c.create()); + QVERIFY(obj); } qmlClearTypeRegistrations(); @@ -571,7 +572,8 @@ void tst_qqmlmetatype::unregisterAttachedProperties() QCOMPARE(attachedType.attachedPropertiesType(QQmlEnginePrivate::get(&e)), attachedType.metaObject()); - QVERIFY(c.create()); + QScopedPointer obj(c.create()); + QVERIFY(obj); } } -- cgit v1.2.3