QOpenGLContext: Handle versionFunctions like other data

While probably not common, it is not unthinkable that one does
a destroy() - create() on a QOpenGLContext while relying on the
versioned function wrappers. This is likely broken at the moment
since the internal data is not released on destroy(), only when
the QOpenGLContext is deleted. This differs from any other similar
data (the portable function resolvers, QOpenGLTexture backing data,
etc.) which are all dropped and nulled out in destroy().

Also remove the bizarre comment in the dtor which must be something
from Qt 4 / QGLWidget times.

Note that this does not fix the associated problem since that only
relies on the standard mechanism that leads to fully destroying
and then recreating the QOpenGLContext when the window changes.

Task-number: QTBUG-109171
Change-Id: Id265a1d208ffae3792a0608c29324e840ce690dc
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
(cherry picked from commit 3bad6d597071186be51d537d2cda786caf879a6c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Laszlo Agocs 2022-12-06 16:40:12 +01:00 committed by Qt Cherry-pick Bot
parent 3b6a6b36e8
commit 6385e154db

View File

@ -362,10 +362,6 @@ bool QOpenGLContext::create()
QOpenGLContextPrivate::~QOpenGLContextPrivate()
{
//do not delete the QOpenGLContext handle here as it is deleted in
//QWidgetPrivate::deleteTLSysExtra()
delete versionFunctions;
}
void QOpenGLContextPrivate::adopt(QPlatformOpenGLContext *context)
@ -416,6 +412,9 @@ void QOpenGLContext::destroy()
}
d->textureFunctions = nullptr;
delete d->versionFunctions;
d->versionFunctions = nullptr;
if (d->vaoHelperDestroyCallback) {
Q_ASSERT(d->vaoHelper);
d->vaoHelperDestroyCallback(d->vaoHelper);