From cbc1a217bfc8b5c6dd94f0448f19245c43eb05e0 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Tue, 18 Aug 2015 17:23:16 +0900 Subject: [PATCH] eo - fix bug vector when unparenting of an eo obj may affect others it is possible that a destructor/parent_set override or function could go modifying the children list of objects in a parent, this the EINA_LIST_FREE may actually miss objects in the process since within the "free" func the list may have been altered etc. @fix --- src/lib/eo/eo_base_class.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index 93d5715..fe52203 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -977,11 +977,21 @@ EOLIAN static void _eo_base_destructor(Eo *obj, Eo_Base_Data *pd) { Eo *child; + Eo_Base_Data *child_pd; DBG("%p - %s.", obj, eo_class_name_get(MY_CLASS)); - EINA_LIST_FREE(pd->children, child) - eo_do(child, eo_parent_set(NULL)); + // special removal - remove from children list by hand after getting + // child handle in case unparent method is overridden and does + // extra things like removes other children too later on in the list + while (pd->children) + { + child = eina_list_data_get(pd->children); + child_pd = eo_data_scope_get(child, EO_BASE_CLASS); + pd->children = eina_list_remove_list(pd->children, pd->children); + child_pd->parent_list = NULL; + eo_do(child, eo_parent_set(NULL)); + } _eo_generic_data_del_all(pd); _wref_destruct(pd); -- 2.7.4