From 85a126c288c608132e6254a51f43a0146d380fef Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 11 May 2020 20:42:59 +0200 Subject: rhi: Fix crashing Controls autotests due to shadereffect lifetime issues Make the QSGShaderEffectNode base class a QObject, the subclass (QSGRhiShaderEffectNode) is already a QObject so we lose nothing. This way we can get rid of the textureChanged() signal from the shadereffectmanager (the object living on the gui thread), and so the node (living on the render thread) does not need to do emit m_mgr->textureChanged() on the render thread. The signal emission in itself was perfectly fine, except when m_mgr happened to be destroyed already in case the node outlived the gui thread's item (and m_mgr). After the change we have something that is closer to what the direct OpenGL implementation did - and some of the interfaces in QSGContext get a lot cleaner in fact because the node can be instantiated on its own, without the involving the shadereffectmanager object that does not even live on the render thread. Change-Id: Ibb918cc3eaa08faddb8b8e5dfa3e34b212161703 Reviewed-by: Eirik Aavitsland --- src/quick/items/qquickgenericshadereffect.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/quick/items/qquickgenericshadereffect.cpp') diff --git a/src/quick/items/qquickgenericshadereffect.cpp b/src/quick/items/qquickgenericshadereffect.cpp index a3d04f5dd3..b7f52a8146 100644 --- a/src/quick/items/qquickgenericshadereffect.cpp +++ b/src/quick/items/qquickgenericshadereffect.cpp @@ -269,12 +269,14 @@ QSGNode *QQuickGenericShaderEffect::handleUpdatePaintNode(QSGNode *oldNode, QQui if (!node) { QSGRenderContext *rc = QQuickWindowPrivate::get(m_item->window())->context; - node = rc->sceneGraphContext()->createShaderEffectNode(rc, mgr); + node = rc->sceneGraphContext()->createShaderEffectNode(rc); if (!node) { qWarning("No shader effect node"); return nullptr; } m_dirty = QSGShaderEffectNode::DirtyShaderAll; + connect(node, &QSGShaderEffectNode::textureChanged, + this, &QQuickGenericShaderEffect::markGeometryDirtyAndUpdateIfSupportsAtlas); } QSGShaderEffectNode::SyncData sd; @@ -369,7 +371,6 @@ QSGGuiThreadShaderEffectManager *QQuickGenericShaderEffect::shaderEffectManager( if (m_mgr) { connect(m_mgr, SIGNAL(logAndStatusChanged()), m_item, SIGNAL(logChanged())); connect(m_mgr, SIGNAL(logAndStatusChanged()), m_item, SIGNAL(statusChanged())); - connect(m_mgr, SIGNAL(textureChanged()), this, SLOT(markGeometryDirtyAndUpdateIfSupportsAtlas())); connect(m_mgr, &QSGGuiThreadShaderEffectManager::shaderCodePrepared, this, &QQuickGenericShaderEffect::shaderCodePrepared); } } -- cgit v1.2.3