aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgwindowsrenderloop.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@sletta.org>2014-09-19 09:52:25 +0200
committerGunnar Sletta <gunnar@sletta.org>2014-09-24 15:03:37 +0200
commitc2706491906c053f5d38ddc0558a993bbf7cfd3e (patch)
tree9ad959a949e88c087f38cc501e6f2bc53f9ba44f /src/quick/scenegraph/qsgwindowsrenderloop.cpp
parent37c52cf6453a91127bcf54f1506fe7eaffd563ad (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 'src/quick/scenegraph/qsgwindowsrenderloop.cpp')
-rw-r--r--src/quick/scenegraph/qsgwindowsrenderloop.cpp48
1 files changed, 17 insertions, 31 deletions
diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
index de1160064d..10eba74607 100644
--- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp
+++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
@@ -185,14 +185,6 @@ void QSGWindowsRenderLoop::show(QQuickWindow *window)
void QSGWindowsRenderLoop::hide(QQuickWindow *window)
{
RLDEBUG("hide");
-
- for (int i=0; i<m_windows.size(); ++i) {
- if (m_windows.at(i).window == window) {
- m_windows.removeAt(i);
- break;
- }
- }
-
// The expose event is queued while hide is sent synchronously, so
// the value might not be updated yet. (plus that the windows plugin
// sends exposed=true when it goes to hidden, so it is doubly broken)
@@ -200,47 +192,41 @@ void QSGWindowsRenderLoop::hide(QQuickWindow *window)
// anyoneShowing will report the right value.
if (window->isExposed())
handleObscurity();
-
if (!m_gl)
return;
-
- QQuickWindowPrivate *cd = QQuickWindowPrivate::get(window);
- m_gl->makeCurrent(window);
- cd->fireAboutToStop();
- cd->cleanupNodesOnShutdown();
-
- // If this is the last tracked window, check for persistent SG and GL and
- // potentially clean up.
- if (m_windows.size() == 0) {
- if (!cd->persistentSceneGraph) {
- QQuickWindowPrivate::get(window)->context->invalidate();
- QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
- if (!cd->persistentGLContext) {
- delete m_gl;
- m_gl = 0;
- }
- }
- }
+ QQuickWindowPrivate::get(window)->fireAboutToStop();
}
void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window)
{
RLDEBUG("windowDestroyed");
+ for (int i=0; i<m_windows.size(); ++i) {
+ if (m_windows.at(i).window == window) {
+ m_windows.removeAt(i);
+ break;
+ }
+ }
+
hide(window);
- // If this is the last tracked window, clean up SG and GL.
+ QQuickWindowPrivate *d = QQuickWindowPrivate::get(window);
+ if (m_gl)
+ m_gl->makeCurrent(window);
+ d->cleanupNodesOnShutdown();
if (m_windows.size() == 0) {
- QQuickWindowPrivate::get(window)->context->invalidate();
+ d->context->invalidate();
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
delete m_gl;
m_gl = 0;
+ } else if (m_gl) {
+ m_gl->doneCurrent();
}
}
bool QSGWindowsRenderLoop::anyoneShowing() const
{
foreach (const WindowData &wd, m_windows)
- if (wd.window->isExposed() && wd.window->size().isValid())
+ if (wd.window->isVisible() && wd.window->isExposed() && wd.window->size().isValid())
return true;
return false;
}
@@ -251,7 +237,7 @@ void QSGWindowsRenderLoop::exposureChanged(QQuickWindow *window)
if (windowData(window) == 0)
return;
- if (window->isExposed()) {
+ if (window->isExposed() && window->isVisible()) {
// Stop non-visual animation timer as we now have a window rendering
if (m_animationTimer && anyoneShowing()) {