From 0c461dcae28e20cc55920b45d611f22348f12e62 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 22 Jan 2015 13:26:24 +0100 Subject: [PATCH] Avoid crashes when resetting the same material or geometry. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We still need to call markDirty() though, to avoid changing behavior. Change-Id: I9df00e8d1cbe95bfae96b9ba9162bd6f226b5bdc Reviewed-by: Florian Hänel Reviewed-by: Laszlo Agocs --- src/quick/scenegraph/coreapi/qsgnode.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/quick/scenegraph/coreapi/qsgnode.cpp b/src/quick/scenegraph/coreapi/qsgnode.cpp index 7f78318..b14c622 100644 --- a/src/quick/scenegraph/coreapi/qsgnode.cpp +++ b/src/quick/scenegraph/coreapi/qsgnode.cpp @@ -787,7 +787,7 @@ QSGBasicGeometryNode::~QSGBasicGeometryNode() void QSGBasicGeometryNode::setGeometry(QSGGeometry *geometry) { - if (flags() & OwnsGeometry) + if ((flags() & OwnsGeometry) != 0 && m_geometry != geometry) delete m_geometry; m_geometry = geometry; markDirty(DirtyGeometry); @@ -954,7 +954,7 @@ void QSGGeometryNode::setRenderOrder(int order) */ void QSGGeometryNode::setMaterial(QSGMaterial *material) { - if (flags() & OwnsMaterial) + if ((flags() & OwnsMaterial) != 0 && m_material != material) delete m_material; m_material = material; #ifndef QT_NO_DEBUG @@ -985,7 +985,7 @@ void QSGGeometryNode::setMaterial(QSGMaterial *material) */ void QSGGeometryNode::setOpaqueMaterial(QSGMaterial *material) { - if (flags() & OwnsOpaqueMaterial) + if ((flags() & OwnsOpaqueMaterial) != 0 && m_opaque_material != m_material) delete m_opaque_material; m_opaque_material = material; #ifndef QT_NO_DEBUG -- 2.7.4