Commit 91e2c5d7 authored by Gunnar Sletta's avatar Gunnar Sletta Committed by The Qt Project
Browse files

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: default avatarLaszlo Agocs <laszlo.agocs@digia.com>
parent 2818f64c
dev 5.10 5.11 5.12 5.12.1 5.12.10 5.12.11 5.12.12 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.12.7 5.12.8 5.12.9 5.13 5.13.0 5.13.1 5.13.2 5.14 5.14.0 5.14.1 5.14.2 5.15 5.15.0 5.15.1 5.15.2 5.3 5.4 5.5 5.6 5.7 5.8 5.9 5.9.8 6.0 6.0.0 6.1 6.1.0 6.1.1 6.1.2 6.1.3 6.2 6.2.0 6.2.1 6.2.2 old/5.2 wip/cmake wip/dbus wip/gc wip/itemviews wip/nacl wip/new-backend wip/pointerhandler wip/propertycache-refactor wip/qquickdeliveryagent wip/scenegraphng wip/tizen wip/webassembly v5.15.0-alpha1 v5.14.1 v5.14.0 v5.14.0-rc2 v5.14.0-rc1 v5.14.0-beta3 v5.14.0-beta2 v5.14.0-beta1 v5.14.0-alpha1 v5.13.2 v5.13.1 v5.13.0 v5.13.0-rc3 v5.13.0-rc2 v5.13.0-rc1 v5.13.0-beta4 v5.13.0-beta3 v5.13.0-beta2 v5.13.0-beta1 v5.13.0-alpha1 v5.12.7 v5.12.6 v5.12.5 v5.12.4 v5.12.3 v5.12.2 v5.12.1 v5.12.0 v5.12.0-rc2 v5.12.0-rc1 v5.12.0-beta4 v5.12.0-beta3 v5.12.0-beta2 v5.12.0-beta1 v5.12.0-alpha1 v5.11.3 v5.11.2 v5.11.1 v5.11.0 v5.11.0-rc2 v5.11.0-rc1 v5.11.0-beta4 v5.11.0-beta3 v5.11.0-beta2 v5.11.0-beta1 v5.11.0-alpha1 v5.10.1 v5.10.0 v5.10.0-rc3 v5.10.0-rc2 v5.10.0-rc1 v5.10.0-beta4 v5.10.0-beta3 v5.10.0-beta2 v5.10.0-beta1 v5.10.0-alpha1 v5.9.9 v5.9.8 v5.9.7 v5.9.6 v5.9.5 v5.9.4 v5.9.3 v5.9.2 v5.9.1 v5.9.0 v5.9.0-rc2 v5.9.0-rc1 v5.9.0-beta4 v5.9.0-beta3 v5.9.0-beta2 v5.9.0-beta1 v5.9.0-alpha1 v5.8.0 v5.8.0-rc1 v5.8.0-beta1 v5.8.0-alpha1 v5.7.1 v5.7.0 v5.7.0-rc1 v5.7.0-beta1 v5.7.0-alpha1 v5.6.3 v5.6.2 v5.6.1 v5.6.1-1 v5.6.0 v5.6.0-rc1 v5.6.0-beta1 v5.6.0-alpha1 v5.5.1 v5.5.0 v5.5.0-rc1 v5.5.0-beta1 v5.5.0-alpha1 v5.4.2 v5.4.1 v5.4.0 v5.4.0-rc1 v5.4.0-beta1 v5.4.0-alpha1 v5.3.2 v5.3.1 v5.3.0 v5.3.0-rc1 v5.3.0-beta1 v5.3.0-alpha1 v5.2.1
No related merge requests found
Showing with 104 additions and 1 deletion
...@@ -238,6 +238,8 @@ void QSGGuiThreadRenderLoop::hide(QQuickWindow *window) ...@@ -238,6 +238,8 @@ void QSGGuiThreadRenderLoop::hide(QQuickWindow *window)
m_windows.remove(window); m_windows.remove(window);
QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window); QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
if (gl)
gl->makeCurrent(window);
cd->cleanupNodesOnShutdown(); cd->cleanupNodesOnShutdown();
if (m_windows.size() == 0) { if (m_windows.size() == 0) {
......
...@@ -240,7 +240,11 @@ void QSGWindowsRenderLoop::hide(QQuickWindow *window) ...@@ -240,7 +240,11 @@ void QSGWindowsRenderLoop::hide(QQuickWindow *window)
if (window->isExposed()) if (window->isExposed())
handleObscurity(); handleObscurity();
if (!m_gl)
return;
QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window); QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
m_gl->makeCurrent(window);
cd->cleanupNodesOnShutdown(); cd->cleanupNodesOnShutdown();
// If this is the last tracked window, check for persistent SG and GL and // If this is the last tracked window, check for persistent SG and GL and
......
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 2.2
Rectangle {
width: 200
height: 200
color: "steelblue"
Rectangle {
width: 150
height: 150
anchors.centerIn: parent
color: "palegreen"
rotation: 45
Text {
rotation: -45
text: "Simple QML.."
anchors.centerIn: parent
}
}
}
...@@ -11,4 +11,5 @@ QT += core-private gui-private qml-private quick-private testlib ...@@ -11,4 +11,5 @@ QT += core-private gui-private qml-private quick-private testlib
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
OTHER_FILES += \ OTHER_FILES += \
data/render_OutOfFloatRange.qml data/render_OutOfFloatRange.qml \
data/simple.qml
...@@ -58,6 +58,8 @@ private slots: ...@@ -58,6 +58,8 @@ private slots:
void render_data(); void render_data();
void render(); void render();
void hideWithOtherContext();
}; };
template <typename T> class ScopedList : public QList<T> { template <typename T> class ScopedList : public QList<T> {
...@@ -401,6 +403,40 @@ void tst_SceneGraph::render() ...@@ -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" #include "tst_scenegraph.moc"
QTEST_MAIN(tst_SceneGraph) QTEST_MAIN(tst_SceneGraph)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment