From 0ca2b46893f73ec1dff9440cd462f9c64b989335 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 17 Sep 2013 15:05:04 +0200 Subject: 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 Reviewed-by: Alan Alpert --- tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/auto/quick/qquickwindow/tst_qquickwindow.cpp') 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 #include #include +#include #include "../../shared/util.h" #include "../shared/visualtestutil.h" #include @@ -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(component.create()); + QVERIFY(window); + window->show(); + QTest::qWaitForWindowExposed(window); + QQuickWindow *transient = Q_NULLPTR; + QTRY_VERIFY(transient = window->property("transientWindow").value()); + QTest::qWaitForWindowExposed(transient); + + // Unload the inner window (in nested Loaders) and make sure it doesn't crash + QQuickLoader *loader = window->property("loader1").value(); + loader->setActive(false); + QTRY_VERIFY(!transient->isVisible()); +} + // QTBUG-32004 void tst_qquickwindow::qobjectEventFilter_touch() { -- cgit v1.2.3