Fixed tst_QGL::destroyFBOAfterContext().

Properly free QOpenGLContext in QGLContext::reset(), if we own it.

Change-Id: Ibd913283cf8b3b8a4dc6295a878a22a3989309a7
Reviewed-on: http://codereview.qt.nokia.com/4320
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
bb10
Samuel Rødal 2011-09-07 09:30:53 +02:00 committed by Jørgen Lind
parent fa0407bdb5
commit e2be53891f
3 changed files with 13 additions and 2 deletions

View File

@ -1532,6 +1532,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
q->setDevice(dev);
guiGlContext = 0;
ownContext = false;
fbo = 0;
crWin = false;
initDone = false;

View File

@ -299,6 +299,8 @@ public:
void swapRegion(const QRegion &region);
QOpenGLContext *guiGlContext;
bool ownContext;
void setupSharing();
QGLFormat glFormat;

View File

@ -148,7 +148,9 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
widget->winId();//make window
}
delete d->guiGlContext;
if (d->ownContext)
delete d->guiGlContext;
d->ownContext = true;
QOpenGLContext *shareGlContext = shareContext ? shareContext->d_func()->guiGlContext : 0;
d->guiGlContext = new QOpenGLContext;
d->guiGlContext->setFormat(winFormat);
@ -180,8 +182,13 @@ void QGLContext::reset()
d->initDone = false;
QGLContextGroup::removeShare(this);
if (d->guiGlContext) {
d->guiGlContext->setQGLContextHandle(0,0);
if (d->ownContext)
delete d->guiGlContext;
else
d->guiGlContext->setQGLContextHandle(0,0);
d->guiGlContext = 0;
}
d->ownContext = false;
}
void QGLContext::makeCurrent()
@ -385,6 +392,7 @@ QGLContext::QGLContext(QOpenGLContext *context)
d->init(0, QGLFormat::fromSurfaceFormat(context->format()));
d->guiGlContext = context;
d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext);
d->ownContext = false;
d->valid = context->isValid();
d->setupSharing();
}