[clutter] actor: Fix child insertion issues
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] actor: Fix child insertion issues
- Date: Mon, 16 Jan 2012 23:55:44 +0000 (UTC)
commit 813eef432548dd8bd1acfd3def86543d5530e24d
Author: Emmanuele Bassi <ebassi gnome org>
Date: Sun Dec 18 20:57:02 2011 +0000
actor: Fix child insertion issues
The insert_child_at_index, insert_below and insert_above messed up the
first and last child pointers in various cases. This commit fixes all
the instances of first and last child pointers being stale or set to
NULL.
clutter/clutter-actor.c | 45 ++++++++++++++++++++++++++++++++++++++-------
1 files changed, 38 insertions(+), 7 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index b26240e..9ca4a67 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -9429,6 +9429,9 @@ insert_child_at_index (ClutterActor *self,
child->priv->next_sibling = tmp;
self->priv->first_child = child;
+
+ if (self->priv->last_child == NULL)
+ self->priv->last_child = child;
}
else if (index < 0)
{
@@ -9441,6 +9444,9 @@ insert_child_at_index (ClutterActor *self,
child->priv->next_sibling = NULL;
self->priv->last_child = child;
+
+ if (self->priv->first_child == NULL)
+ self->priv->first_child = child;
}
else
{
@@ -9483,13 +9489,26 @@ insert_child_above (ClutterActor *self,
sibling = self->priv->last_child;
child->priv->prev_sibling = sibling;
- child->priv->next_sibling = NULL;
if (sibling != NULL)
- sibling->priv->next_sibling = child;
+ {
+ ClutterActor *tmp = sibling->priv->next_sibling;
+
+ child->priv->next_sibling = tmp;
+
+ if (tmp != NULL)
+ tmp->priv->prev_sibling = child;
+
+ sibling->priv->next_sibling = child;
+ }
+ else
+ child->priv->next_sibling = NULL;
- if (self->priv->last_child == sibling)
+ if (self->priv->last_child == NULL || self->priv->last_child == sibling)
self->priv->last_child = child;
+
+ if (self->priv->first_child == NULL)
+ self->priv->first_child = sibling != NULL ? sibling : child;
}
static void
@@ -9502,14 +9521,27 @@ insert_child_below (ClutterActor *self,
if (sibling == NULL)
sibling = self->priv->first_child;
- child->priv->prev_sibling = NULL;
child->priv->next_sibling = sibling;
if (sibling != NULL)
- sibling->priv->prev_sibling = child;
+ {
+ ClutterActor *tmp = sibling->priv->prev_sibling;
+
+ child->priv->prev_sibling = tmp;
- if (self->priv->first_child == sibling)
+ if (tmp != NULL)
+ tmp->priv->next_sibling = child;
+
+ sibling->priv->prev_sibling = child;
+ }
+ else
+ child->priv->prev_sibling = NULL;
+
+ if (self->priv->first_child == NULL || self->priv->first_child == sibling)
self->priv->first_child = child;
+
+ if (self->priv->last_child == NULL)
+ self->priv->last_child = sibling != NULL ? sibling : child;
}
typedef void (* ClutterActorAddChildFunc) (ClutterActor *parent,
@@ -9680,7 +9712,6 @@ clutter_actor_insert_child_at_index (ClutterActor *self,
g_return_if_fail (CLUTTER_IS_ACTOR (child));
g_return_if_fail (self != child);
g_return_if_fail (child->priv->parent == NULL);
- g_return_if_fail (index_ < self->priv->n_children);
clutter_actor_add_child_internal (self, child,
insert_child_at_index,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]