[clutter/clutter-1.10] actor: Make _clutter_actor_foreach_child() safe again
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/clutter-1.10] actor: Make _clutter_actor_foreach_child() safe again
- Date: Wed, 11 Apr 2012 11:53:00 +0000 (UTC)
commit 0e96d2a4281e3798c313f421f9e696a52e581e25
Author: Emmanuele Bassi <ebassi linux intel com>
Date: Thu Mar 29 15:52:51 2012 +0100
actor: Make _clutter_actor_foreach_child() safe again
We were using g_list_foreach() prior to the first Apocalypse, and that
function is resilient against changes to the list while iterating it;
since we are not using a GList any more, we need handle this case
ourselves.
clutter/clutter-actor.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 3a500d9..203809b 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -15809,15 +15809,25 @@ _clutter_actor_foreach_child (ClutterActor *self,
ClutterForeachCallback callback,
gpointer user_data)
{
- ClutterActorPrivate *priv = self->priv;
ClutterActor *iter;
gboolean cont;
- for (cont = TRUE, iter = priv->first_child;
- cont && iter != NULL;
- iter = iter->priv->next_sibling)
+ if (self->priv->first_child == NULL)
+ return TRUE;
+
+ cont = TRUE;
+ iter = self->priv->first_child;
+
+ /* we use this form so that it's safe to change the children
+ * list while iterating it
+ */
+ while (cont && iter != NULL)
{
+ ClutterActor *next = iter->priv->next_sibling;
+
cont = callback (iter, user_data);
+
+ iter = next;
}
return cont;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]