diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-08-13 15:57:22 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-08-14 13:59:14 +0000 |
commit | b70fcaa7ce9c9afa068679f67aa909c6de8992ff (patch) | |
tree | 43042287d8b0f979e719cb07bbe03aae0c8a14cc /src/quick/scenegraph/qsgrenderloop.cpp | |
parent | f18fefc3ba74cc9da37843271f141388e98c7fc2 (diff) |
Minor cleanup and logic fix in basic renderloop
The (gl) condition is clearly an oversight, the branch should be taken
if either gl or rhi are valid.
Change-Id: Ieb0a9aeec996f8940716f9fdafe90525b60fc248
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'src/quick/scenegraph/qsgrenderloop.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgrenderloop.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp index ec835fe3bd..db657cd7df 100644 --- a/src/quick/scenegraph/qsgrenderloop.cpp +++ b/src/quick/scenegraph/qsgrenderloop.cpp @@ -383,20 +383,23 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window) QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); bool current = false; - if (gl) { - QSurface *surface = window; - // There may be no platform window if the window got closed. - if (!window->handle()) - surface = offscreenSurface; + if (gl || rhi) { if (rhi) { + // Direct OpenGL calls in user code need a current context, like + // when rendering; ensure this (no-op when not running on GL). + // Also works when there is no handle() anymore. rhi->makeThreadLocalNativeContextCurrent(); current = true; } else { + QSurface *surface = window; + // There may be no platform window if the window got closed. + if (!window->handle()) + surface = offscreenSurface; current = gl->makeCurrent(surface); } + if (Q_UNLIKELY(!current)) + qCDebug(QSG_LOG_RENDERLOOP, "cleanup without an OpenGL context"); } - if (Q_UNLIKELY(!current)) - qCDebug(QSG_LOG_RENDERLOOP, "cleanup without an OpenGL context"); #if QT_CONFIG(quick_shadereffect) QSGRhiShaderEffectNode::cleanupMaterialTypeCache(); |