summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-06-17 16:23:35 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2011-07-13 14:35:00 +0100
commit807eb9990d88181f48c67802acaf40be80ebc2d5 (patch)
treed7bd313ee7ea1ea665696c4f044e418597857245
parented3004816e3fe81f3705f8cb469956ebf319ec32 (diff)
downloadclutter-807eb9990d88181f48c67802acaf40be80ebc2d5.tar.gz
group: Handle list modification while destroying children
This makes the dispose code that destroys children resilient against priv->children being modified during child destruction. (cherry picked from commit ddc9eb5fa5326904852951a3fa00159bed75fde1) Signed-off-by: Emmanuele Bassi <ebassi@gnome.org>
-rw-r--r--clutter/clutter-group.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/clutter/clutter-group.c b/clutter/clutter-group.c
index d6c98973e..41cb7d097 100644
--- a/clutter/clutter-group.c
+++ b/clutter/clutter-group.c
@@ -350,12 +350,14 @@ clutter_group_dispose (GObject *object)
ClutterGroup *self = CLUTTER_GROUP (object);
ClutterGroupPrivate *priv = self->priv;
- if (priv->children)
+ /* Note: we are careful to consider that destroying children could
+ * have the side-effect of destroying other children so
+ * priv->children may be modified during clutter_actor_destroy. */
+ while (priv->children)
{
- g_list_foreach (priv->children, (GFunc) clutter_actor_destroy, NULL);
- g_list_free (priv->children);
-
- priv->children = NULL;
+ ClutterActor *child = priv->children->data;
+ priv->children = g_list_delete_link (priv->children, priv->children);
+ clutter_actor_destroy (child);
}
if (priv->layout)