eo - destruction - ensure child is removed from parent child list
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Thu, 20 Aug 2015 03:50:52 +0000 (12:50 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Thu, 20 Aug 2015 03:53:53 +0000 (12:53 +0900)
this follows on from cbc1a217bfc8b5c6dd94f0448f19245c43eb05e0 as this
code was correct, but was then causing bugs due to children staying in
their parent lists. this should never have happened and this is really
bad. this fixes this and ensures children on destruction are gone from
their parent lists.

@fix

src/lib/eo/eo_base_class.c

index fe52203..9f8252b 100644 (file)
@@ -977,7 +977,6 @@ 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));
 
@@ -987,11 +986,18 @@ _eo_base_destructor(Eo *obj, Eo_Base_Data *pd)
    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));
      }
+   // remove child from its parent on destruction - ha to be done
+   if (pd->parent)
+     {
+        Eo_Base_Data *parent_pd;
+
+        parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS);
+        parent_pd->children = eina_list_remove_list(parent_pd->children,
+                                                    pd->parent_list);
+        pd->parent_list = NULL;
+     }
 
    _eo_generic_data_del_all(pd);
    _wref_destruct(pd);