From 6385e154dbe6a0d6e9ed87fa7cbaca904ff97cee Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 6 Dec 2022 16:40:12 +0100 Subject: [PATCH] QOpenGLContext: Handle versionFunctions like other data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit 3bad6d597071186be51d537d2cda786caf879a6c) Reviewed-by: Qt Cherry-pick Bot --- src/gui/kernel/qopenglcontext.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index 4a9d62829f7..a018f867636 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -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);