Gui: fix memory leak in QGuiGLThreadContext

`QCoreApplicationPrivate::cleanupThreadData` calls
`~QGuiGLThreadContext`, which calls
`QOpenGLContextPrivate::setCurrentContext`, which creates a new
`QGuiGLThreadContext`, which is not destroyed anymore.

since `~QGuiGLThreadContext` sets a nullptr we exit early.

Fixes: QTBUG-124538
Change-Id: I51e40fcf8fd1169a4dfd336fac9c82f44d42f68e
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit d139642aefde2d00683cf29f3875ccfae6c66779)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tim Blechmann 2024-04-19 14:30:15 +08:00 committed by Qt Cherry-pick Bot
parent fe6e1c2191
commit f17ff4be2c

View File

@ -154,6 +154,9 @@ QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context
qWarning("No QTLS available. currentContext won't work");
return nullptr;
}
if (!context)
return nullptr;
threadContext = new QGuiGLThreadContext;
qwindow_context_storage()->setLocalData(threadContext);
}