mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 08:30:42 -05:00
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.
This commit is contained in:
parent
7e377b5aee
commit
813eef4325
@ -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;
|
||||
|
||||
if (self->priv->last_child == 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 == 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;
|
||||
|
||||
if (self->priv->first_child == sibling)
|
||||
child->priv->prev_sibling = tmp;
|
||||
|
||||
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,
|
||||
|
Loading…
Reference in New Issue
Block a user