From: Kim Motoyoshi Kalland Date: Fri, 10 Jun 2011 11:35:50 +0000 (+0200) Subject: Added QSGNode::removeAllChildNodes(). X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=199635ad73b223cd993869ce088faef8d1ecad0c;p=konrad%2Fqtdeclarative.git Added QSGNode::removeAllChildNodes(). --- diff --git a/src/declarative/items/qsgcanvas.cpp b/src/declarative/items/qsgcanvas.cpp index 614c826..f38e0b5 100644 --- a/src/declarative/items/qsgcanvas.cpp +++ b/src/declarative/items/qsgcanvas.cpp @@ -1615,10 +1615,8 @@ void QSGCanvasPrivate::updateDirtyNode(QSGItem *item) } } - if (dirty & QSGItemPrivate::ChildrenUpdateMask) { - while (itemPriv->childContainerNode()->childCount()) - itemPriv->childContainerNode()->removeChildNode(itemPriv->childContainerNode()->childAtIndex(0)); - } + if (dirty & QSGItemPrivate::ChildrenUpdateMask) + itemPriv->childContainerNode()->removeAllChildNodes(); if (effectRefEffectivelyChanged) { QSGNode *parent = itemPriv->clipNode; @@ -1651,10 +1649,8 @@ void QSGCanvasPrivate::updateDirtyNode(QSGItem *item) if (dirty & QSGItemPrivate::ChildrenUpdateMask) { QSGNode *groupNode = itemPriv->groupNode; - if (groupNode) { - for (int count = groupNode->childCount(); count; --count) - groupNode->removeChildNode(groupNode->childAtIndex(0)); - } + if (groupNode) + groupNode->removeAllChildNodes(); QList orderedChildren = itemPriv->paintOrderChildItems(); int ii = 0; diff --git a/src/declarative/scenegraph/coreapi/qsgnode.cpp b/src/declarative/scenegraph/coreapi/qsgnode.cpp index b0a5f04..347aad6 100644 --- a/src/declarative/scenegraph/coreapi/qsgnode.cpp +++ b/src/declarative/scenegraph/coreapi/qsgnode.cpp @@ -305,7 +305,7 @@ void QSGNode::insertChildNodeAfter(QSGNode *node, QSGNode *after) /*! - Removes \a node fromt his node's list of children. + Removes \a node from this node's list of children. */ void QSGNode::removeChildNode(QSGNode *node) @@ -321,6 +321,20 @@ void QSGNode::removeChildNode(QSGNode *node) /*! + Removes all child nodes from this node's list of children. + */ + +void QSGNode::removeAllChildNodes() +{ + while (!m_children.isEmpty()) { + QSGNode *node = m_children.takeLast(); + node->markDirty(DirtyNodeRemoved); + node->m_parent = 0; + } +} + + +/*! Sets the flag \a f on this node if \a enabled is true; otherwise clears the flag. diff --git a/src/declarative/scenegraph/coreapi/qsgnode.h b/src/declarative/scenegraph/coreapi/qsgnode.h index fa45e0f..b2444d5 100644 --- a/src/declarative/scenegraph/coreapi/qsgnode.h +++ b/src/declarative/scenegraph/coreapi/qsgnode.h @@ -118,6 +118,7 @@ public: QSGNode *parent() const { return m_parent; } void removeChildNode(QSGNode *node); + void removeAllChildNodes(); void prependChildNode(QSGNode *node); void appendChildNode(QSGNode *node); void insertChildNodeBefore(QSGNode *node, QSGNode *before);