Remove st_container_remove_all & rewrite st_container_destroy_children
1. Both functions leaked the nodes in priv->children 2. st_container_remove_all wasn't properly updating first_child and last_child 3. remove_all() is almost never right since it won't cause signal handlers on the children to be removed. In the rare cases where it might be needed the caller can simply use clutter_container_remove(). https://bugzilla.gnome.org/show_bug.cgi?id=640781
This commit is contained in:
@@ -35,6 +35,7 @@ struct _StContainerPrivate
|
||||
GList *children;
|
||||
ClutterActor *first_child;
|
||||
ClutterActor *last_child;
|
||||
gboolean block_update_pseude_classes;
|
||||
};
|
||||
|
||||
static void clutter_container_iface_init (ClutterContainerIface *iface);
|
||||
@@ -50,6 +51,9 @@ st_container_update_pseudo_classes (StContainer *container)
|
||||
ClutterActor *first_child, *last_child;
|
||||
StContainerPrivate *priv = container->priv;
|
||||
|
||||
if (priv->block_update_pseude_classes)
|
||||
return;
|
||||
|
||||
first_item = priv->children;
|
||||
first_child = first_item ? first_item->data : NULL;
|
||||
if (first_child != priv->first_child)
|
||||
@@ -91,28 +95,6 @@ st_container_update_pseudo_classes (StContainer *container)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* st_container_remove_all:
|
||||
* @container: An #StContainer
|
||||
*
|
||||
* Removes all child actors from @container.
|
||||
*/
|
||||
void
|
||||
st_container_remove_all (StContainer *container)
|
||||
{
|
||||
StContainerPrivate *priv = container->priv;
|
||||
|
||||
/* copied from clutter_group_remove_all() */
|
||||
while (priv->children)
|
||||
{
|
||||
ClutterActor *child = priv->children->data;
|
||||
priv->children = priv->children->next;
|
||||
|
||||
clutter_container_remove_actor (CLUTTER_CONTAINER (container), child);
|
||||
}
|
||||
st_container_update_pseudo_classes (container);
|
||||
}
|
||||
|
||||
/**
|
||||
* st_container_destroy_children:
|
||||
* @container: An #StContainer
|
||||
@@ -124,13 +106,14 @@ st_container_destroy_children (StContainer *container)
|
||||
{
|
||||
StContainerPrivate *priv = container->priv;
|
||||
|
||||
while (priv->children)
|
||||
{
|
||||
ClutterActor *child = priv->children->data;
|
||||
priv->children = priv->children->next;
|
||||
priv->block_update_pseude_classes = TRUE;
|
||||
|
||||
clutter_actor_destroy (child);
|
||||
}
|
||||
while (priv->children)
|
||||
clutter_actor_destroy (priv->children->data);
|
||||
|
||||
priv->block_update_pseude_classes = FALSE;
|
||||
|
||||
st_container_update_pseudo_classes (container);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -53,7 +53,6 @@ struct _StContainerClass {
|
||||
|
||||
GType st_container_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void st_container_remove_all (StContainer *container);
|
||||
void st_container_destroy_children (StContainer *container);
|
||||
|
||||
GList * st_container_get_focus_chain (StContainer *container);
|
||||
|
Reference in New Issue
Block a user