diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 637cfc55a8d..3cfdcc549c1 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) { Q_D(QGLContext); - 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