From bfb271b40332240f40c79dabf8f78f7a68293286 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Tue, 9 Feb 2010 19:19:44 +0000 Subject: [PATCH] box: port a ClutterGroup::foreach fix to ClutterBox 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 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/clutter/clutter-box.c b/clutter/clutter-box.c index a76d6e1..2667adb 100644 --- a/clutter/clutter-box.c +++ b/clutter/clutter-box.c @@ -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 -- 2.7.4