[clutter/wip/apocalypses/apocalypse-1: 51/92] actor: Fix child insertion issues
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/apocalypses/apocalypse-1: 51/92] actor: Fix child insertion issues
- Date: Tue, 3 Jan 2012 22:24:28 +0000 (UTC)
commit 8612b1449c8069691269b90417b21d737ece3404
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 623f6c9..749e5ad 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -9436,6 +9436,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)
{
@@ -9448,6 +9451,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
{
@@ -9490,13 +9496,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
@@ -9509,14 +9528,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,
@@ -9687,7 +9719,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]