aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickgenericshadereffect.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-05-11 20:42:59 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-05-13 14:12:57 +0200
commit85a126c288c608132e6254a51f43a0146d380fef (patch)
tree20c3853fdf29bfb50c81e98c72a38cd529a47339 /src/quick/items/qquickgenericshadereffect.cpp
parent525fe67ac2eefd37c1758a64fc519e9886475983 (diff)
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 <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/quick/items/qquickgenericshadereffect.cpp')
-rw-r--r--src/quick/items/qquickgenericshadereffect.cpp5
1 files changed, 3 insertions, 2 deletions
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);
}
}