summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-05-17 17:21:40 +0200
committerAndras Timar <andras.timar@collabora.com>2018-05-23 13:56:27 +0200
commit9d01f30b46cb23915342f7a04165750b3f493f49 (patch)
treefbe6cf6310d69ec7c60e474f63ed2f494df4d0c5 /vcl
parent28baf76d293fdc6fba13c1718ea8f705bdc25757 (diff)
tdf#104893 vcl opengl: fix assert failure when starting chart editing
OpenGLContext::prepareForYield() assumed that in case we have a current context, then it's the last one, but that's not the case for chart windows since commit 78b100ec9cb0db2f7b33ece5ad3287a67a37246f (only init the OpenGL context if we need it, 2016-06-07), which creates an OpenGLContext instance (which is then the last one in the context list) but explicitly doesn't initialize it (so that it would become the current one). Fix the problem by resetting not the last but the last current context. (cherry picked from commit 2a6171ed6fb85b3419dcf5cf1346cf1eec447987) Change-Id: Ie0e96927473290590cd6333e5cdcb7daa009431b Reviewed-on: https://gerrit.libreoffice.org/54516 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl> (cherry picked from commit 014a573a05bc69e0883a9e5fccdc7bed72b0a62e)
Diffstat (limited to 'vcl')
-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());
}