diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-11-06 13:06:26 -0800 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2014-11-10 09:48:51 +0100 |
commit | b5fb59fc5fa8d180daa1cb95f12238657a53bbc2 (patch) | |
tree | 308250492b50a49b3469a9edd989ac77d0cb317a /src | |
parent | 3d389f2a47dad538925ca1916e889c4bbc48fbac (diff) |
Fix not having a context when cleaning up on Windows
The same old issue surfaces in the windows render loop too.
The basic render loop is already fixed, apply a similar patch
to the windows one too.
Task-number: QTBUG-42213
Change-Id: I07068315f5164014e329b8ce061947c97ae9da61
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/scenegraph/qsgwindowsrenderloop.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp index 070d6b82fd..1213c7e771 100644 --- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp +++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp @@ -38,6 +38,7 @@ #include <QtGui/QScreen> #include <QtGui/QGuiApplication> +#include <QtGui/QOffscreenSurface> #include <QtQuick/private/qsgcontext_p.h> #include <QtQuick/private/qquickwindow_p.h> @@ -210,15 +211,29 @@ void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window) hide(window); QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); - if (m_gl) - m_gl->makeCurrent(window); + bool current = false; + QScopedPointer<QOffscreenSurface> offscreenSurface; + if (m_gl) { + QSurface *surface = window; + // There may be no platform window if the window got closed. + if (!window->handle()) { + offscreenSurface.reset(new QOffscreenSurface); + offscreenSurface->setFormat(m_gl->format()); + offscreenSurface->create(); + surface = offscreenSurface.data(); + } + current = m_gl->makeCurrent(surface); + } + if (Q_UNLIKELY(!current)) + qCDebug(QSG_LOG_RENDERLOOP) << "cleanup without an OpenGL context"; + d->cleanupNodesOnShutdown(); if (m_windows.size() == 0) { d->context->invalidate(); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); delete m_gl; m_gl = 0; - } else if (m_gl) { + } else if (m_gl && current) { m_gl->doneCurrent(); } } |