[clutter] actor: Allow insert_child_at_index to add a child at the end with an index



commit e3151228958e66fc8a0271c6cffd26234aa9ab69
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Feb 13 17:12:41 2012 -0500

    actor: Allow insert_child_at_index to add a child at the end with an index
    
    If we have N children and the user passes N (or a number beyond N) to
    clutter_actor_insert_child_at_index, we should respond by adding the
    child at the end, not silently doing nothing.

 clutter/clutter-actor.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 3bb8b96..08900b4 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -9929,7 +9929,7 @@ insert_child_at_index (ClutterActor *self,
       child->priv->prev_sibling = NULL;
       child->priv->next_sibling = tmp;
     }
-  else if (index_ < 0)
+  else if (index_ < 0 || index_ >= self->priv->n_children)
     {
       ClutterActor *tmp = self->priv->last_child;
 
@@ -10240,7 +10240,8 @@ clutter_actor_add_child (ClutterActor *self,
  * @index_: the index
  *
  * Inserts @child into the list of children of @self, using the
- * given @index_.
+ * given @index_. If @index_ is greater than the number of children
+ * in @self, or is less than 0, then the new child is added at the end.
  *
  * This function will acquire a reference on @child that will only
  * be released when calling clutter_actor_remove_child().



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