diff options
author | Gunnar Sletta <gunnar@sletta.org> | 2014-09-19 09:52:25 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar@sletta.org> | 2014-09-24 15:03:37 +0200 |
commit | c2706491906c053f5d38ddc0558a993bbf7cfd3e (patch) | |
tree | 9ad959a949e88c087f38cc501e6f2bc53f9ba44f /tests/auto/quick/qquickwindow | |
parent | 37c52cf6453a91127bcf54f1506fe7eaffd563ad (diff) |
Fix cleanup of non-threaded render loops.
They would unconditionally call cleanupNodesOnShutdown on hide(), but
QQuickWindow::sceneGraphInvalidated would only be emitted if this was
the last window being hidden, leading to an inconsistent state in the
application.
Since the non-threaded render loops do not support releasing resources
(there is one OpenGL context and one QSGRenderContext shared between
all windows) we delay cleanup until the window is destroyed.
This change also make the render loops track the windows until they
are destroyed, similar to what the threaded one does. The purpose of
this is to, in the case of dangling windows, only trigger invalidation
of the scene graph when the last QQuickWindow is destroyed through
QSGRenderLoop::cleanup().
Task-number: QTBUG-41210
Change-Id: I7e12a4f726ebb3e7935c822b6046abb3590c583a
Reviewed-by: Ulf Hermann <ulf.hermann@digia.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'tests/auto/quick/qquickwindow')
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index aecd28f44b..dfb1ac5bfe 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -1188,6 +1188,7 @@ void tst_qquickwindow::headless() QVERIFY(QTest::qWaitForWindowExposed(window)); QVERIFY(window->isVisible()); + bool threaded = window->openglContext()->thread() != QThread::currentThread(); QSignalSpy initialized(window, SIGNAL(sceneGraphInitialized())); QSignalSpy invalidated(window, SIGNAL(sceneGraphInvalidated())); @@ -1202,8 +1203,10 @@ void tst_qquickwindow::headless() window->hide(); window->releaseResources(); - QTRY_COMPARE(invalidated.size(), 1); - QVERIFY(window->openglContext() == 0); + if (threaded) { + QTRY_COMPARE(invalidated.size(), 1); + QVERIFY(window->openglContext() == 0); + } // Destroy the native windowing system buffers window->destroy(); @@ -1213,7 +1216,8 @@ void tst_qquickwindow::headless() window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); - QTRY_COMPARE(initialized.size(), 1); + if (threaded) + QTRY_COMPARE(initialized.size(), 1); QVERIFY(window->openglContext() != 0); // Verify that the visual output is the same @@ -1536,6 +1540,7 @@ void tst_qquickwindow::hideThenDelete() QSignalSpy *openglDestroyed = 0; QSignalSpy *sgInvalidated = 0; + bool threaded = false; { QQuickWindow window; @@ -1548,6 +1553,7 @@ void tst_qquickwindow::hideThenDelete() window.show(); QTest::qWaitForWindowExposed(&window); + threaded = window.openglContext()->thread() != QThread::currentThread(); openglDestroyed = new QSignalSpy(window.openglContext(), SIGNAL(aboutToBeDestroyed())); sgInvalidated = new QSignalSpy(&window, SIGNAL(sceneGraphInvalidated())); @@ -1556,15 +1562,17 @@ void tst_qquickwindow::hideThenDelete() QTRY_VERIFY(!window.isExposed()); - if (!persistentSG) { - QVERIFY(sgInvalidated->size() > 0); - if (!persistentGL) - QVERIFY(openglDestroyed->size() > 0); - else + if (threaded) { + if (!persistentSG) { + QVERIFY(sgInvalidated->size() > 0); + if (!persistentGL) + QVERIFY(openglDestroyed->size() > 0); + else + QVERIFY(openglDestroyed->size() == 0); + } else { + QVERIFY(sgInvalidated->size() == 0); QVERIFY(openglDestroyed->size() == 0); - } else { - QVERIFY(sgInvalidated->size() == 0); - QVERIFY(openglDestroyed->size() == 0); + } } } |