diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-11-02 12:27:50 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-11-02 13:12:39 +0000 |
commit | b882fae50e12d32709f12621e5cfc4dab2def964 (patch) | |
tree | 80fb442c395fef21f5370742c238561623ef8ab4 | |
parent | 7ae55889805bc1d62c0268938eeca20bec9b773c (diff) |
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 <mitch.curtis@qt.io>
-rw-r--r-- | tests/auto/snippets/tst_snippets.cpp | 8 |
1 files 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<QObject> 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<QQuickWindow *>(root); + QQuickWindow *window = qobject_cast<QQuickWindow *>(root.data()); if (!window) { QQuickView *view = new QQuickView; - view->setContent(url, &component, root); + view->setContent(url, &component, root.data()); window = view; } |