aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlimport
diff options
context:
space:
mode:
authorAmanda Hamblin-Trué <amanda.hamblin-true@qt.io>2023-08-03 14:42:49 +0200
committerAmanda Hamblin-Trué <amanda.hamblin-true@qt.io>2023-08-21 08:45:47 +0200
commit690cff76d4a061d2c1dd0c697f3e1f4c43268719 (patch)
tree4efe0c4fffb54501bb2e40e5a3f354acfa3f914f /tests/auto/qml/qqmlimport
parent1fedad3f11d92e32b9549978b64e17f61b29e812 (diff)
tst_qqmlimport: Clean up memory management
Task-number: QTBUG-115222 Change-Id: I82186e3690e0e4805f4abe2be626186bcf40100d Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlimport')
-rw-r--r--tests/auto/qml/qqmlimport/tst_qqmlimport.cpp13
1 files changed, 4 insertions, 9 deletions
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<QQuickView> window = std::make_unique<QQuickView>();
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<QQuickView>();
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<QQmlApplicationEngine> test = std::make_unique<QQmlApplicationEngine>(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()