box: port a ClutterGroup::foreach fix to ClutterBox
authorRobert Bragg <robert@linux.intel.com>
Tue, 9 Feb 2010 19:19:44 +0000 (19:19 +0000)
committerRobert Bragg <robert@linux.intel.com>
Fri, 12 Feb 2010 12:31:24 +0000 (12:31 +0000)
ClutterGroup::foreach was recently changed (ref: ce030a3fce) to use
g_list_foreach() to iterate the children instead of manually iterating
the list so it would safely handle calls like:

  clutter_container_foreach (container, clutter_actor_destroy);

  (In this example clutter_actor_destroy will result in the current
   list item being iterated being freed.)

clutter/clutter-box.c

index a76d6e1..2667adb 100644 (file)
@@ -171,8 +171,11 @@ clutter_box_real_foreach (ClutterContainer *container,
 {
   ClutterBoxPrivate *priv = CLUTTER_BOX (container)->priv;
 
-  for (l = priv->children; l != NULL; l = l->next)
-    (* callback) (l->data, user_data);
+  /* Using g_list_foreach instead of iterating the list manually
+     because it has better protection against the current node being
+     removed. This will happen for example if someone calls
+     clutter_container_foreach(container, clutter_actor_destroy) */
+  g_list_foreach (priv->children, (GFunc) callback, user_data);
 }
 
 static void