Fix null pointer access in QQuickOpenGLShaderEffectMaterialCache
If a QQuickWindow is destroyed without ever being rendered, then there won't be any QOpenGLContext in QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache. Same goes for QQuickWidgetRenderControl. Fixes: QTBUG-65236 Change-Id: I2742505d147bc8444b46688170d33fbb2844f2ac Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
74a5ce0266
commit
6c08137faf
|
@ -366,6 +366,7 @@ class QQuickOpenGLShaderEffectMaterialCache : public QObject
|
|||
public:
|
||||
static QQuickOpenGLShaderEffectMaterialCache *get(bool create = true) {
|
||||
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
||||
Q_ASSERT(ctx);
|
||||
QQuickOpenGLShaderEffectMaterialCache *me = ctx->findChild<QQuickOpenGLShaderEffectMaterialCache *>(QStringLiteral("__qt_ShaderEffectCache"), Qt::FindDirectChildrenOnly);
|
||||
if (!me && create) {
|
||||
me = new QQuickOpenGLShaderEffectMaterialCache();
|
||||
|
|
|
@ -192,7 +192,8 @@ void QQuickRenderControlPrivate::windowDestroyed()
|
|||
QQuickWindowPrivate::get(window)->animationController = nullptr;
|
||||
|
||||
#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
|
||||
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
|
||||
if (QOpenGLContext::currentContext())
|
||||
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
|
||||
#endif
|
||||
|
||||
window = nullptr;
|
||||
|
|
|
@ -334,7 +334,8 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window)
|
|||
qCDebug(QSG_LOG_RENDERLOOP, "cleanup without an OpenGL context");
|
||||
|
||||
#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
|
||||
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
|
||||
if (current)
|
||||
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
|
||||
#endif
|
||||
|
||||
d->cleanupNodesOnShutdown();
|
||||
|
|
Loading…
Reference in New Issue