Added QSGNode::removeAllChildNodes().
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>
Fri, 10 Jun 2011 11:35:50 +0000 (13:35 +0200)
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>
Fri, 10 Jun 2011 11:35:50 +0000 (13:35 +0200)
src/declarative/items/qsgcanvas.cpp
src/declarative/scenegraph/coreapi/qsgnode.cpp
src/declarative/scenegraph/coreapi/qsgnode.h

index 614c826..f38e0b5 100644 (file)
@@ -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<QSGItem *> orderedChildren = itemPriv->paintOrderChildItems();
         int ii = 0;
index b0a5f04..347aad6 100644 (file)
@@ -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.
 
index fa45e0f..b2444d5 100644 (file)
@@ -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);