layout: Do not create a LayoutMeta on remove
When calling remove_child_meta() we check if there is a LayoutMeta already attached to the Actor, and if that LayoutMeta matches the (manager, container, actor) tuple. If the LayoutMeta does not match, though, we create a new LayoutMeta instance -- in order to remove it right afterwards. Instead of doing this, we can simply check for a matching LayoutMeta and if present, remove it. In case of an existing, non-matching LayoutMeta, we're left with a dangling instance, but it does not matter: the removal happens in the unparenting phase of a ClutterContainer, so either the Actor will be destroyed and thus the LayoutMeta will be disposed along with it; or it will be parented to another container, and thus the LayoutMeta will be replaced.
This commit is contained in:
parent
5a63e8af8f
commit
5a14db5089
@ -381,6 +381,27 @@ create_child_meta (ClutterLayoutManager *manager,
|
||||
return klass->create_child_meta (manager, container, actor);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
has_child_meta (ClutterLayoutManager *manager,
|
||||
ClutterContainer *container,
|
||||
ClutterActor *actor)
|
||||
{
|
||||
ClutterLayoutMeta *layout_meta = NULL;
|
||||
|
||||
layout_meta = g_object_get_qdata (G_OBJECT (actor), quark_layout_meta);
|
||||
if (layout_meta != NULL)
|
||||
{
|
||||
ClutterChildMeta *child_meta = CLUTTER_CHILD_META (layout_meta);
|
||||
|
||||
if (layout_meta->manager == manager &&
|
||||
child_meta->container == container &&
|
||||
child_meta->actor == actor)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static inline ClutterLayoutMeta *
|
||||
get_child_meta (ClutterLayoutManager *manager,
|
||||
ClutterContainer *container,
|
||||
@ -550,7 +571,7 @@ clutter_layout_manager_remove_child_meta (ClutterLayoutManager *manager,
|
||||
g_return_if_fail (CLUTTER_IS_CONTAINER (container));
|
||||
g_return_if_fail (CLUTTER_IS_ACTOR (actor));
|
||||
|
||||
if (get_child_meta (manager, container, actor))
|
||||
if (has_child_meta (manager, container, actor))
|
||||
g_object_set_qdata (G_OBJECT (actor), quark_layout_meta, NULL);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user