Fix use-after-free in testcase.

The call to setActive does a deleteLater on the window. Then the QTRY_*
macros run the event loop, thereby deleting the window. So, after
wrapping the window in a QPointer, that pointer must either be null, or
the window shouldn't be visible.

Change-Id: Ib3fc5c5284bd5dae378a0f6a17117b262b9a3687
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Erik Verbruggen 2014-08-06 15:18:08 +02:00 committed by J-P Nurmi
parent 5b6be6456f
commit ca248a5b8e
1 changed files with 2 additions and 2 deletions

View File

@ -1768,14 +1768,14 @@ void tst_qquickwindow::unloadSubWindow()
QVERIFY(window);
window->show();
QTest::qWaitForWindowExposed(window);
QQuickWindow *transient = Q_NULLPTR;
QPointer<QQuickWindow> transient;
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());
QTRY_VERIFY(transient.isNull() || !transient->isVisible());
}
// QTBUG-32004