diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-04-21 08:45:13 +0300 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-04-21 15:15:29 +0000 |
commit | 8dc1ddc14cbd146ad14f66c09a449afaad9f4885 (patch) | |
tree | 9210e542072f2c3949bcc09b3c5c1b36fd4febbb | |
parent | 20d1bdc650dfcaa1c84d297f412fe7c836972990 (diff) |
Fix QQuickApplicationWindow::isComponentComplete()
It has to default to true to ensure that a QQuickApplicationWindow
instantiated in C++ is not stuck to false forever. When instantiated
by the QML engine, it is set to false during the QML component
initialization phase from classBegin() to componentComple().
Change-Id: Ieba2bbfb8fc0296b8cb28df91b12bcc55dd31bf4
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/quicktemplates2/qquickapplicationwindow.cpp | 3 | ||||
-rw-r--r-- | tests/auto/applicationwindow/tst_applicationwindow.cpp | 23 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp index a92900a5..0cd78502 100644 --- a/src/quicktemplates2/qquickapplicationwindow.cpp +++ b/src/quicktemplates2/qquickapplicationwindow.cpp @@ -138,7 +138,7 @@ class QQuickApplicationWindowPrivate : public QQuickItemChangeListener public: QQuickApplicationWindowPrivate() - : complete(false), + : complete(true), background(nullptr), contentItem(nullptr), header(nullptr), @@ -693,6 +693,7 @@ bool QQuickApplicationWindow::isComponentComplete() const void QQuickApplicationWindow::classBegin() { Q_D(QQuickApplicationWindow); + d->complete = false; QQuickWindowQmlImpl::classBegin(); d->resolveFont(); } diff --git a/tests/auto/applicationwindow/tst_applicationwindow.cpp b/tests/auto/applicationwindow/tst_applicationwindow.cpp index b72bb8f2..61f84673 100644 --- a/tests/auto/applicationwindow/tst_applicationwindow.cpp +++ b/tests/auto/applicationwindow/tst_applicationwindow.cpp @@ -74,6 +74,7 @@ private slots: void focusAfterPopupClosed(); void clearFocusOnDestruction(); void layout(); + void componentComplete(); }; void tst_applicationwindow::qmlCreation() @@ -774,6 +775,28 @@ void tst_applicationwindow::layout() QCOMPARE(content->height(), qreal(window->height())); } +class FriendlyApplicationWindow : public QQuickApplicationWindow +{ + friend class tst_applicationwindow; +}; + +void tst_applicationwindow::componentComplete() +{ + FriendlyApplicationWindow cppWindow; + QVERIFY(cppWindow.isComponentComplete()); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick.Controls 2.2; ApplicationWindow { }", QUrl()); + + FriendlyApplicationWindow *qmlWindow = static_cast<FriendlyApplicationWindow *>(component.beginCreate(engine.rootContext())); + QVERIFY(qmlWindow); + QVERIFY(!qmlWindow->isComponentComplete()); + + component.completeCreate(); + QVERIFY(qmlWindow->isComponentComplete()); +} + QTEST_MAIN(tst_applicationwindow) #include "tst_applicationwindow.moc" |