[clutter] Do not use set_parent()/unparent() internally



commit 8462b5ba458bb6fff93ecf7c8b74c6cf3101fd3c
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Thu Nov 17 15:23:05 2011 +0000

    Do not use set_parent()/unparent() internally
    
    Use add_child()/remove_child() instead.

 clutter/clutter-actor.c   |   12 ++++++------
 clutter/clutter-box.c     |    6 +++---
 clutter/clutter-group.c   |    4 ++--
 clutter/clutter-texture.c |   25 +++++++++++++++----------
 4 files changed, 26 insertions(+), 21 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index b6e00dd..d4b3f73 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -3746,7 +3746,7 @@ clutter_actor_dispose (GObject *object)
           clutter_container_remove_actor (CLUTTER_CONTAINER (parent), self);
         }
       else
-        clutter_actor_unparent (self);
+        clutter_actor_remove_child (parent, self);
     }
 
   /* parent should be gone */
@@ -8259,8 +8259,8 @@ clutter_actor_add_child (ClutterActor *self,
 
   if (child->priv->parent_actor != NULL)
     {
-      g_warning ("Cannot set a parent on an actor which has a parent.\n"
-		 "You must use clutter_actor_unparent() first.\n");
+      g_warning ("Cannot set a parent on an actor which has a parent. "
+		 "You must use clutter_actor_remove_child() first.");
       return;
     }
 
@@ -8542,19 +8542,19 @@ clutter_actor_reparent (ClutterActor *self,
       if (CLUTTER_IS_CONTAINER (priv->parent_actor) &&
           !CLUTTER_ACTOR_IS_INTERNAL_CHILD (self))
         {
-          ClutterContainer *parent = CLUTTER_CONTAINER (priv->parent_actor);
+          ClutterContainer *parent = CLUTTER_CONTAINER (old_parent);
 
           /* this will have to call unparent() */
           clutter_container_remove_actor (parent, self);
         }
       else
-        clutter_actor_unparent (self);
+        clutter_actor_remove_child (old_parent, self);
 
       /* Note, will call parent() */
       if (CLUTTER_IS_CONTAINER (new_parent))
         clutter_container_add_actor (CLUTTER_CONTAINER (new_parent), self);
       else
-        clutter_actor_set_parent (self, new_parent);
+        clutter_actor_add_child (new_parent, self);
 
       /* we emit the ::parent-set signal once */
       g_signal_emit (self, actor_signals[PARENT_SET], 0, old_parent);
diff --git a/clutter/clutter-box.c b/clutter/clutter-box.c
index 76e2f34..e293258 100644
--- a/clutter/clutter-box.c
+++ b/clutter/clutter-box.c
@@ -165,7 +165,7 @@ clutter_box_real_add (ClutterContainer *container,
   else
     priv->children = l;
 
-  clutter_actor_set_parent (actor, CLUTTER_ACTOR (container));
+  clutter_actor_add_child (CLUTTER_ACTOR (container), actor);
 
   clutter_actor_queue_relayout (actor);
 
@@ -183,7 +183,7 @@ clutter_box_real_remove (ClutterContainer *container,
   g_object_ref (actor);
 
   priv->children = g_list_remove (priv->children, actor);
-  clutter_actor_unparent (actor);
+  clutter_actor_remove_child (CLUTTER_ACTOR (container), actor);
 
   clutter_actor_queue_relayout (CLUTTER_ACTOR (container));
 
@@ -974,7 +974,7 @@ clutter_box_pack_at (ClutterBox   *box,
                                   actor,
                                   position);
 
-  clutter_actor_set_parent (actor, CLUTTER_ACTOR (box));
+  clutter_actor_add_child (CLUTTER_ACTOR (box), actor);
   clutter_actor_queue_relayout (actor);
 
   /* we need to explicitly call this, because we're not going through
diff --git a/clutter/clutter-group.c b/clutter/clutter-group.c
index 04ca502..aac8abe 100644
--- a/clutter/clutter-group.c
+++ b/clutter/clutter-group.c
@@ -111,7 +111,7 @@ clutter_group_real_add (ClutterContainer *container,
   g_object_ref (actor);
 
   priv->children = g_list_append (priv->children, actor);
-  clutter_actor_set_parent (actor, CLUTTER_ACTOR (container));
+  clutter_actor_add_child (CLUTTER_ACTOR (container), actor);
 
   /* queue a relayout, to get the correct positioning inside
    * the ::actor-added signal handlers
@@ -134,7 +134,7 @@ clutter_group_real_remove (ClutterContainer *container,
   g_object_ref (actor);
 
   priv->children = g_list_remove (priv->children, actor);
-  clutter_actor_unparent (actor);
+  clutter_actor_remove_child (CLUTTER_ACTOR (container), actor);
 
   /* queue a relayout, to get the correct positioning inside
    * the ::actor-removed signal handlers
diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c
index d736f8c..2191aef 100644
--- a/clutter/clutter-texture.c
+++ b/clutter/clutter-texture.c
@@ -2386,12 +2386,14 @@ on_fbo_parent_change (ClutterActor        *actor,
   ClutterActor        *parent = CLUTTER_ACTOR(texture);
 
   while ((parent = clutter_actor_get_parent (parent)) != NULL)
-    if (parent == actor)
-      {
-        g_warning ("Offscreen texture is ancestor of source!");
-        /* Desperate but will avoid infinite loops */
-        clutter_actor_unparent (actor);
-      }
+    {
+      if (parent == actor)
+        {
+          g_warning ("Offscreen texture is ancestor of source!");
+          /* Desperate but will avoid infinite loops */
+          clutter_actor_remove_child (parent, actor);
+        }
+    }
 }
 
 static void
@@ -2544,7 +2546,7 @@ clutter_texture_new_from_actor (ClutterActor *actor)
   /* If the actor doesn't have a parent then claim it so that it will
      get a size allocation during layout */
   if (clutter_actor_get_parent (actor) == NULL)
-    clutter_actor_set_parent (actor, CLUTTER_ACTOR (texture));
+    clutter_actor_add_child (CLUTTER_ACTOR (texture), actor);
 
   /* Connect up any signals which could change our underlying size */
   g_signal_connect (actor,
@@ -2606,11 +2608,14 @@ texture_fbo_free_resources (ClutterTexture *texture)
 
   if (priv->fbo_source != NULL)
     {
+      ClutterActor *parent;
+
+      parent = clutter_actor_get_parent (priv->fbo_source);
+
       /* If we parented the texture then unparent it again so that it
 	 will lose the reference */
-      if (clutter_actor_get_parent (priv->fbo_source)
-	  == CLUTTER_ACTOR (texture))
-	clutter_actor_unparent (priv->fbo_source);
+      if (parent == CLUTTER_ACTOR (texture))
+	clutter_actor_remove_child (parent, priv->fbo_source);
 
       g_signal_handlers_disconnect_by_func
                             (priv->fbo_source,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]