aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgdefaultimagenode.cpp
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2013-10-15 09:12:09 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-21 13:38:42 +0200
commit486d367e8086e63f51707e78c07ef77fa6240f0a (patch)
tree6722f818311ce2bd537944f314fb8d60c81b516c /src/quick/scenegraph/qsgdefaultimagenode.cpp
parent19d6806716946081bc08169d3f702acf33560a89 (diff)
Prevent badly formed texture nodes in the scene graph.
A texture based node without a valid texture is not allowed, as the material and the renderer will only tolerate well-formed nodes. If a node is missing any part of its material state it should not be in the scene graph in the first place. Because of an "optimization" in QSGDefaultImageNode::setTexture and QSGSimpleTextureNode::setTexture, we must temporarily set the texture to 0 to ensure that it gets updated properly. This temporarily puts the node into an invalid state which can lead to crashes when QSGNode::markDirty() reaches the renderer. Task-number: QTBUG-34062 Change-Id: Ic1735c9b974b90b3684262de9589133c961bac6e Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultimagenode.cpp')
-rw-r--r--src/quick/scenegraph/qsgdefaultimagenode.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/quick/scenegraph/qsgdefaultimagenode.cpp b/src/quick/scenegraph/qsgdefaultimagenode.cpp
index 349a92ac7f..11d0e5dbeb 100644
--- a/src/quick/scenegraph/qsgdefaultimagenode.cpp
+++ b/src/quick/scenegraph/qsgdefaultimagenode.cpp
@@ -298,15 +298,13 @@ void QSGDefaultImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode)
void QSGDefaultImageNode::setTexture(QSGTexture *texture)
{
- if (texture == m_material.texture())
- return;
+ Q_ASSERT(texture);
m_material.setTexture(texture);
m_materialO.setTexture(texture);
m_smoothMaterial.setTexture(texture);
- // Texture cleanup
- if (texture)
- m_material.setFlag(QSGMaterial::Blending, texture->hasAlphaChannel());
+ m_material.setFlag(QSGMaterial::Blending, texture->hasAlphaChannel());
+
markDirty(DirtyMaterial);
// Because the texture can be a different part of the atlas, we need to update it...