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 <jorgen.lind@digia.com>
This commit is contained in:
Laszlo Agocs 2014-04-01 14:18:15 +02:00 committed by The Qt Project
parent e39f30a0d2
commit 581d10bdf2

View File

@ -2934,8 +2934,9 @@ void QGLContext::setFormat(const QGLFormat &format)
void QGLContext::setDevice(QPaintDevice *pDev) void QGLContext::setDevice(QPaintDevice *pDev)
{ {
Q_D(QGLContext); Q_D(QGLContext);
if (isValid()) // Do not touch the valid flag here. The context is either a new one and
reset(); // valid is not yet set or it is adapted from a valid QOpenGLContext in which
// case it must remain valid.
d->paintDevice = pDev; d->paintDevice = pDev;
if (d->paintDevice && (d->paintDevice->devType() != QInternal::Widget if (d->paintDevice && (d->paintDevice->devType() != QInternal::Widget
&& d->paintDevice->devType() != QInternal::Pixmap && d->paintDevice->devType() != QInternal::Pixmap