diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2013-09-17 15:05:04 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@digia.com> | 2014-06-30 10:32:57 +0200 |
commit | 0ca2b46893f73ec1dff9440cd462f9c64b989335 (patch) | |
tree | c21b8ef652702d1dda9af3780ebd088379b09914 /tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | |
parent | 5da2576633bc0d0150a8607a30ab1f66f040bb19 (diff) |
Avoid double deletion of QQuickWindow
It's uncertain why 4fc0df58b8458052a818e3e970a97457882808e6 added
the call to sendPostedEvents(0, QEvent::DeferredDelete) but now we can
see that it easily results in the destructor calling itself, and
therefore double-deleting its own d_ptr. removePostedEvents seems
safer to ensure that the window cannot be doubly deleted, in spite
of the qdoc warning that "You should never need to call this function."
Task-number: QTBUG-33436
Change-Id: I4873ebe179dde551407eba1f6baac5f03ca7f177
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'tests/auto/quick/qquickwindow/tst_qquickwindow.cpp')
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index b05146fa3a..b8f9102775 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -47,6 +47,7 @@ #include <QtQml/QQmlEngine> #include <QtQml/QQmlComponent> #include <QtQuick/private/qquickrectangle_p.h> +#include <QtQuick/private/qquickloader_p.h> #include "../../shared/util.h" #include "../shared/visualtestutil.h" #include <QSignalSpy> @@ -347,6 +348,8 @@ private slots: void crashWhenHoverItemDeleted(); + void unloadSubWindow(); + void qobjectEventFilter_touch(); void qobjectEventFilter_key(); void qobjectEventFilter_mouse(); @@ -1705,6 +1708,26 @@ void tst_qquickwindow::crashWhenHoverItemDeleted() } } +// QTBUG-33436 +void tst_qquickwindow::unloadSubWindow() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("unloadSubWindow.qml")); + QQuickWindow *window = qobject_cast<QQuickWindow *>(component.create()); + QVERIFY(window); + window->show(); + QTest::qWaitForWindowExposed(window); + QQuickWindow *transient = Q_NULLPTR; + QTRY_VERIFY(transient = window->property("transientWindow").value<QQuickWindow*>()); + QTest::qWaitForWindowExposed(transient); + + // Unload the inner window (in nested Loaders) and make sure it doesn't crash + QQuickLoader *loader = window->property("loader1").value<QQuickLoader*>(); + loader->setActive(false); + QTRY_VERIFY(!transient->isVisible()); +} + // QTBUG-32004 void tst_qquickwindow::qobjectEventFilter_touch() { |