From 690cff76d4a061d2c1dd0c697f3e1f4c43268719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amanda=20Hamblin-Tru=C3=A9?= Date: Thu, 3 Aug 2023 14:42:49 +0200 Subject: tst_qqmlimport: Clean up memory management Task-number: QTBUG-115222 Change-Id: I82186e3690e0e4805f4abe2be626186bcf40100d Reviewed-by: Sami Shalayel --- tests/auto/qml/qqmlimport/tst_qqmlimport.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'tests/auto/qml/qqmlimport') diff --git a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp index ea912c8384..692548ee5b 100644 --- a/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp +++ b/tests/auto/qml/qqmlimport/tst_qqmlimport.cpp @@ -152,7 +152,7 @@ void tst_QQmlImport::invalidImportUrl() void tst_QQmlImport::testDesignerSupported() { - QQuickView *window = new QQuickView(); + std::unique_ptr window = std::make_unique(); window->engine()->addImportPath(directory()); window->setSource(testFileUrl("testfile_supported.qml")); @@ -164,8 +164,7 @@ void tst_QQmlImport::testDesignerSupported() QQmlImports::setDesignerSupportRequired(true); //imports are cached so we create a new window - delete window; - window = new QQuickView(); + window = std::make_unique(); window->engine()->addImportPath(directory()); window->engine()->clearComponentCache(); @@ -181,21 +180,19 @@ void tst_QQmlImport::testDesignerSupported() QTest::ignoreMessage(QtWarningMsg, warningString.toLocal8Bit()); window->setSource(testFileUrl("testfile_unsupported.qml")); QVERIFY(!window->errors().isEmpty()); - - delete window; } void tst_QQmlImport::uiFormatLoading() { int size = 0; - QQmlApplicationEngine *test = new QQmlApplicationEngine(testFileUrl("TestForm.ui.qml")); + std::unique_ptr test = std::make_unique(testFileUrl("TestForm.ui.qml")); test->addImportPath(directory()); QCOMPARE(test->rootObjects().size(), ++size); QVERIFY(test->rootObjects()[size -1]); QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); - QSignalSpy objectCreated(test, SIGNAL(objectCreated(QObject*,QUrl))); + QSignalSpy objectCreated(test.get(), SIGNAL(objectCreated(QObject*,QUrl))); test->load(testFileUrl("TestForm.ui.qml")); QCOMPARE(objectCreated.size(), size);//one less than rootObjects().size() because we missed the first one QCOMPARE(test->rootObjects().size(), ++size); @@ -220,8 +217,6 @@ void tst_QQmlImport::uiFormatLoading() QCOMPARE(test->rootObjects().size(), ++size); QVERIFY(test->rootObjects()[size -1]); QVERIFY(test->rootObjects()[size -1]->property("success").toBool()); - - delete test; } tst_QQmlImport::tst_QQmlImport() -- cgit v1.2.3