From 9fde7c1723c316a4207ef28e12744c260c883071 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 22 Sep 2011 14:06:05 +1000 Subject: [PATCH] Stop managing lifetime of material Let scenegraph handle it in its own thread. Task-number: QTBUG-21586 Change-Id: I5affcec4abbc79fff0c60e740d2c1cf04e3385f2 Reviewed-on: http://codereview.qt-project.org/5345 Reviewed-by: Qt Sanity Bot Reviewed-by: Gunnar Sletta --- src/declarative/particles/qsgimageparticle.cpp | 14 +++++--------- 1 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/declarative/particles/qsgimageparticle.cpp b/src/declarative/particles/qsgimageparticle.cpp index dd50ce2..872624e 100644 --- a/src/declarative/particles/qsgimageparticle.cpp +++ b/src/declarative/particles/qsgimageparticle.cpp @@ -667,7 +667,6 @@ QSGImageParticle::QSGImageParticle(QSGItem* parent) QSGImageParticle::~QSGImageParticle() { - delete m_material; } QDeclarativeListProperty QSGImageParticle::sprites() @@ -1106,10 +1105,8 @@ QSGGeometryNode* QSGImageParticle::buildParticleNodes() } clearShadows(); - if (m_material) { - delete m_material; + if (m_material) m_material = 0; - } //Setup material QImage colortable; @@ -1212,8 +1209,9 @@ QSGGeometryNode* QSGImageParticle::buildParticleNodes() foreach (QSGGeometryNode* node, m_nodes){ if (node == *(m_nodes.begin())) - continue; - (*(m_nodes.begin()))->appendChildNode(node); + node->setFlag(QSGGeometryNode::OwnsMaterial);//Root node owns the material for memory management purposes + else + (*(m_nodes.begin()))->appendChildNode(node); } return *(m_nodes.begin()); @@ -1224,15 +1222,13 @@ QSGNode *QSGImageParticle::updatePaintNode(QSGNode *, UpdatePaintNodeData *) if (m_pleaseReset){ m_lastLevel = perfLevel; - delete m_rootNode;//Automatically deletes children + delete m_rootNode;//Automatically deletes children, and SG manages material lifetime m_rootNode = 0; m_nodes.clear(); m_idxStarts.clear(); m_lastIdxStart = 0; - if (m_material) - delete m_material; m_material = 0; m_pleaseReset = false; -- 1.7.2.5