tst_qqmlmetatype.cpp: Avoid memory leaks

Change-Id: Ic4ff36e48a1ff5146ec44f58ed416fd24cce5330
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2019-12-19 11:23:46 +01:00
parent 6567ac4362
commit c6e63aa128
1 changed files with 6 additions and 4 deletions

View File

@ -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<QObject> obj(c.create());
QVERIFY(obj);
QQmlType type = QQmlMetaType::qmlType(QString("ImplicitType"), QString(""), 1, 0);
@ -324,7 +324,7 @@ void tst_qqmlmetatype::externalEnums()
qmlRegisterSingletonType<ExternalEnums>("x.y.z", 1, 0, "ExternalEnums", ExternalEnums::create);
QQmlComponent c(&engine, testFileUrl("testExternalEnums.qml"));
QObject *obj = c.create();
QScopedPointer<QObject> 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<QObject> 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<QObject> obj(c.create());
QVERIFY(obj);
}
}