OpenGL: destroy QGLContext allocated by QGLContext::fromOpenGLContext
QGLContext already uses ownContext to identify when it "owns" QOpenGLContext and will delete QOpenGLContext when needed. In the other way QGLContext::fromOpenGLContext creates a QGLContext for QOpenGLContext, and is now using qGLContextDeleteFunction to identify if QOpenGLContext "owns" QGLContext by QGLContext only passing a delete function when QOpenGLContext should delete QGLContext, and by QOpenGLContext calling deleteQGLContext() from destory() to do the destruction avoiding the previous leak and sometimes crash on exit. Change-Id: I65e791776e99b456e4d0c70fc5b5cdb33c975893 Task-number: QTBUG-40286 Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>bb10
parent
e1fed5dc31
commit
3a347a4e70
|
|
@ -538,6 +538,7 @@ bool QOpenGLContext::create()
|
|||
*/
|
||||
void QOpenGLContext::destroy()
|
||||
{
|
||||
deleteQGLContext();
|
||||
Q_D(QOpenGLContext);
|
||||
if (d->platformGLContext)
|
||||
emit aboutToBeDestroyed();
|
||||
|
|
@ -984,6 +985,9 @@ void *QOpenGLContext::qGLContextHandle() const
|
|||
}
|
||||
|
||||
/*!
|
||||
internal: If the delete function is specified QOpenGLContext "owns"
|
||||
the passed context handle and will use the delete function to destroy it.
|
||||
|
||||
\internal
|
||||
*/
|
||||
void QOpenGLContext::setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *))
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ public:
|
|||
void swapRegion(const QRegion ®ion);
|
||||
|
||||
QOpenGLContext *guiGlContext;
|
||||
// true if QGLContext owns the QOpenGLContext (for who deletes who)
|
||||
bool ownContext;
|
||||
|
||||
void setupSharing();
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ bool QGLFormat::hasOpenGL()
|
|||
->hasCapability(QPlatformIntegration::OpenGL);
|
||||
}
|
||||
|
||||
void qDeleteQGLContext(void *handle)
|
||||
static void qDeleteQGLContext(void *handle)
|
||||
{
|
||||
QGLContext *context = static_cast<QGLContext *>(handle);
|
||||
delete context;
|
||||
|
|
@ -177,7 +177,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
|
|||
d->valid = d->guiGlContext->create();
|
||||
|
||||
if (d->valid)
|
||||
d->guiGlContext->setQGLContextHandle(this,qDeleteQGLContext);
|
||||
d->guiGlContext->setQGLContextHandle(this, 0);
|
||||
|
||||
d->glFormat = QGLFormat::fromSurfaceFormat(d->guiGlContext->format());
|
||||
d->setupSharing();
|
||||
|
|
|
|||
Loading…
Reference in New Issue