diff options
author | Gunnar Sletta <gunnar.sletta@digia.com> | 2013-11-18 08:53:13 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-12 08:55:35 +0100 |
commit | 91e2c5d749e38eed93e91b14151faa549e70080f (patch) | |
tree | 7f52a4f1a1106f1e03ebe2b78a9344f646d73762 /tests/auto/quick/scenegraph/tst_scenegraph.cpp | |
parent | 2818f64cafe1ea249288ca8f572081fc58a10111 (diff) |
Safeguard QQuickWindow::hide() against other GL contexts.
If another GL context is bound to another surface on the GUI
thread, we can run into issues while cleaning up the SG nodes.
Task-number: QTBUG-34898
Change-Id: Ifa02b7cdbc7ab38b3a149a21452cc5071498a7d1
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'tests/auto/quick/scenegraph/tst_scenegraph.cpp')
-rw-r--r-- | tests/auto/quick/scenegraph/tst_scenegraph.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index 3b79f01f12..780d5a97db 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -58,6 +58,8 @@ private slots: void render_data(); void render(); + + void hideWithOtherContext(); }; template <typename T> class ScopedList : public QList<T> { @@ -401,6 +403,40 @@ void tst_SceneGraph::render() } } +// Testcase for QTBUG-34898. We make another context current on another surface +// in the GUI thread and hide the QQuickWindow while the other context is +// current on the other window. +void tst_SceneGraph::hideWithOtherContext() +{ + QWindow window; + window.setSurfaceType(QWindow::OpenGLSurface); + window.resize(100, 100); + window.create(); + QOpenGLContext context; + context.create(); + bool renderingOnMainThread = false; + + { + QQuickView view; + view.setSource(QUrl::fromLocalFile("data/simple.qml")); + view.setResizeMode(QQuickView::SizeViewToRootObject); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + renderingOnMainThread = view.openglContext()->thread() == QGuiApplication::instance()->thread(); + + // Make the local context current on the local window... + context.makeCurrent(&window); + } + + // The local context should no longer be the current one. It is not + // rebound because all well behaving Qt/OpenGL applications are + // required to makeCurrent their context again before making any + // GL calls to a new frame (see QOpenGLContext docs). + QVERIFY(!renderingOnMainThread || QOpenGLContext::currentContext() != &context); +} + + #include "tst_scenegraph.moc" QTEST_MAIN(tst_SceneGraph) |