From b882fae50e12d32709f12621e5cfc4dab2def964 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 2 Nov 2017 12:27:50 +0100 Subject: Improve tst_snippets Make sure dynamically created QML components are destroyed when going out of scope, and print out the error when creation fails. Change-Id: Ie0ed785780cb861dd057adda8f4da399dd4986d2 Reviewed-by: Mitch Curtis --- tests/auto/snippets/tst_snippets.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/auto/snippets/tst_snippets.cpp b/tests/auto/snippets/tst_snippets.cpp index 852c98e9..107759ce 100644 --- a/tests/auto/snippets/tst_snippets.cpp +++ b/tests/auto/snippets/tst_snippets.cpp @@ -103,8 +103,8 @@ void tst_Snippets::verify() QUrl url = QUrl::fromLocalFile(input); component.loadUrl(url); - QObject *root = component.create(); - QVERIFY(root); + QScopedPointer root(component.create()); + QVERIFY2(!root.isNull(), qPrintable(component.errorString())); QCOMPARE(component.status(), QQmlComponent::Ready); QVERIFY(component.errors().isEmpty()); @@ -132,10 +132,10 @@ void tst_Snippets::verify() output.insert(index, "-" + applicationStyle.toLower()); } - QQuickWindow *window = qobject_cast(root); + QQuickWindow *window = qobject_cast(root.data()); if (!window) { QQuickView *view = new QQuickView; - view->setContent(url, &component, root); + view->setContent(url, &component, root.data()); window = view; } -- cgit v1.2.3