summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx15
1 files changed, 13 insertions, 2 deletions
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 958c59925db2..200a772e2a36 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -483,8 +483,19 @@ void OpenGLContext::prepareForYield()
SAL_INFO("vcl.opengl", "Unbinding contexts in preparation for yield");
- if( pCurrentCtx->isCurrent() )
- pCurrentCtx->resetCurrent();
+ // Find the first context that is current and reset it.
+ // Usually the last context is the current, but not in case a new
+ // OpenGLContext is created already but not yet initialized.
+ while (pCurrentCtx.is())
+ {
+ if (pCurrentCtx->isCurrent())
+ {
+ pCurrentCtx->resetCurrent();
+ break;
+ }
+
+ pCurrentCtx = pCurrentCtx->mpPrevContext;
+ }
assert (!hasCurrent());
}