From abbe2ebf8baa61edeaa2071fa850d000d565a6ce Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 14 Sep 2009 15:57:31 +0100 Subject: [PATCH] [container] Use a 1:1 mapping between child and ChildMeta Since an actor can only be parented to one container we don't need the extra complications of maintaining a list of ChildMeta objects attached to an actor in the default implementation of the Container interface. --- clutter/clutter-container.c | 50 ++++++++------------------------------------- 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/clutter/clutter-container.c b/clutter/clutter-container.c index 3f2296d..9e6eff8 100644 --- a/clutter/clutter-container.c +++ b/clutter/clutter-container.c @@ -700,23 +700,14 @@ get_child_meta (ClutterContainer *container, ClutterActor *actor) { ClutterContainerIface *iface = CLUTTER_CONTAINER_GET_IFACE (container); + ClutterChildMeta *meta; if (iface->child_meta_type == G_TYPE_INVALID) return NULL; - else - { - ClutterChildMeta *child_meta = NULL; - GSList *list, *iter; - list = g_object_get_qdata (G_OBJECT (container), quark_child_meta); - for (iter = list; iter; iter = g_slist_next (iter)) - { - child_meta = iter->data; - - if (child_meta->actor == actor) - return child_meta; - } - } + meta = g_object_get_qdata (G_OBJECT (actor), quark_child_meta); + if (meta != NULL && meta->actor == actor) + return meta; return NULL; } @@ -726,8 +717,7 @@ create_child_meta (ClutterContainer *container, ClutterActor *actor) { ClutterContainerIface *iface = CLUTTER_CONTAINER_GET_IFACE (container); - ClutterChildMeta *child_meta = NULL; - GSList *data_list = NULL; + ClutterChildMeta *child_meta = NULL; if (iface->child_meta_type == G_TYPE_INVALID) return; @@ -744,9 +734,9 @@ create_child_meta (ClutterContainer *container, "actor", actor, NULL); - data_list = g_object_get_qdata (G_OBJECT (container), quark_child_meta); - data_list = g_slist_prepend (data_list, child_meta); - g_object_set_qdata (G_OBJECT (container), quark_child_meta, data_list); + g_object_set_qdata_full (G_OBJECT (container), quark_child_meta, + child_meta, + (GDestroyNotify) g_object_unref); } static void @@ -758,30 +748,8 @@ destroy_child_meta (ClutterContainer *container, if (iface->child_meta_type == G_TYPE_INVALID) return; - else - { - ClutterChildMeta *child_meta = NULL; - GSList *list = g_object_get_qdata (object, quark_child_meta); - GSList *iter; - for (iter = list; iter; iter = g_slist_next (iter)) - { - child_meta = iter->data; - - if (child_meta->actor == actor) - break; - else - child_meta = NULL; - } - - if (child_meta) - { - list = g_slist_remove (list, child_meta); - g_object_set_qdata (object, quark_child_meta, list); - - g_object_unref (child_meta); - } - } + g_object_set_qdata (object, quark_child_meta, NULL); } /** -- 2.7.4