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:
|
public:
|
||||||
static QQuickOpenGLShaderEffectMaterialCache *get(bool create = true) {
|
static QQuickOpenGLShaderEffectMaterialCache *get(bool create = true) {
|
||||||
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
||||||
|
Q_ASSERT(ctx);
|
||||||
QQuickOpenGLShaderEffectMaterialCache *me = ctx->findChild<QQuickOpenGLShaderEffectMaterialCache *>(QStringLiteral("__qt_ShaderEffectCache"), Qt::FindDirectChildrenOnly);
|
QQuickOpenGLShaderEffectMaterialCache *me = ctx->findChild<QQuickOpenGLShaderEffectMaterialCache *>(QStringLiteral("__qt_ShaderEffectCache"), Qt::FindDirectChildrenOnly);
|
||||||
if (!me && create) {
|
if (!me && create) {
|
||||||
me = new QQuickOpenGLShaderEffectMaterialCache();
|
me = new QQuickOpenGLShaderEffectMaterialCache();
|
||||||
|
|
|
@ -192,6 +192,7 @@ void QQuickRenderControlPrivate::windowDestroyed()
|
||||||
QQuickWindowPrivate::get(window)->animationController = nullptr;
|
QQuickWindowPrivate::get(window)->animationController = nullptr;
|
||||||
|
|
||||||
#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
|
#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
|
||||||
|
if (QOpenGLContext::currentContext())
|
||||||
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
|
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -334,6 +334,7 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window)
|
||||||
qCDebug(QSG_LOG_RENDERLOOP, "cleanup without an OpenGL context");
|
qCDebug(QSG_LOG_RENDERLOOP, "cleanup without an OpenGL context");
|
||||||
|
|
||||||
#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
|
#if QT_CONFIG(quick_shadereffect) && QT_CONFIG(opengl)
|
||||||
|
if (current)
|
||||||
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
|
QQuickOpenGLShaderEffectMaterial::cleanupMaterialCache();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue