path: root/src/opengl/qgl.cpp
diff options
authorLaszlo Agocs <>2014-04-01 14:18:15 +0200
committerThe Qt Project <>2014-04-03 14:18:41 +0200
commit581d10bdf26dacaa36a916744ff5b43ecaa05f77 (patch)
tree7ae213a1a063913e8fd64d2c4426a625ae5db551 /src/opengl/qgl.cpp
parente39f30a0d27608cf112f818f2c63418bfeb93cb3 (diff)
Avoid recreating the underlying context in QGLContext wrappers
QGLContexts created from a QOpenGLContext get their valid flag reset, resulting in creating a totally new underlying context. This is wrong and becomes visible when sharing is expected between contexts (since the QGLContext's underlying QOpenGLContext will not have sharing). Task-number: QTBUG-37893 Change-Id: I8cb37c11dfb400a77e510bf4c8219bedc742309e Reviewed-by: Jørgen Lind <>
Diffstat (limited to 'src/opengl/qgl.cpp')
1 files changed, 3 insertions, 2 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 637cfc55a8..3cfdcc549c 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -2934,8 +2934,9 @@ void QGLContext::setFormat(const QGLFormat &format)
void QGLContext::setDevice(QPaintDevice *pDev)
- if (isValid())
- reset();
+ // Do not touch the valid flag here. The context is either a new one and
+ // valid is not yet set or it is adapted from a valid QOpenGLContext in which
+ // case it must remain valid.
d->paintDevice = pDev;
if (d->paintDevice && (d->paintDevice->devType() != QInternal::Widget
&& d->paintDevice->devType() != QInternal::Pixmap