actor: Implement remove_all_children using ActorIter
authorEmmanuele Bassi <ebassi@gnome.org>
Mon, 13 Feb 2012 08:59:09 +0000 (08:59 +0000)
committerEmmanuele Bassi <ebassi@gnome.org>
Mon, 13 Feb 2012 08:59:09 +0000 (08:59 +0000)
The remove_all_children() method is an ideal candidate for using the
ActorIter API; the end result is more compact and easy to follow.

clutter/clutter-actor.c

index 1920717..946544e 100644 (file)
@@ -10466,24 +10466,18 @@ clutter_actor_remove_child (ClutterActor *self,
 void
 clutter_actor_remove_all_children (ClutterActor *self)
 {
-  ClutterActor *iter;
+  ClutterActorIter iter;
 
   g_return_if_fail (CLUTTER_IS_ACTOR (self));
 
   if (self->priv->n_children == 0)
     return;
 
-  iter = self->priv->first_child;
-  while (iter != NULL)
-    {
-      ClutterActor *next = iter->priv->next_sibling;
-
-      clutter_actor_remove_child_internal (self, iter,
-                                           REMOVE_CHILD_DEFAULT_FLAGS);
-
-      iter = next;
-    }
+  clutter_actor_iter_init (&iter, self);
+  while (clutter_actor_iter_next (&iter, NULL))
+    clutter_actor_iter_remove (&iter);
 
+  /* sanity check */
   g_assert (self->priv->first_child == NULL);
   g_assert (self->priv->last_child == NULL);
   g_assert (self->priv->n_children == 0);