diff options
author | Tom Hacohen <tom@stosb.com> | 2015-08-21 17:19:47 +0100 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2015-08-21 17:23:13 +0100 |
commit | 93ade6f4ce4a336dfcdc748a09dd35003591978b (patch) | |
tree | 261225563b2c21d71d8f63ee300f58a7afefde58 | |
parent | 7aea193a971a395b3afd09a6fa6f1b8985fc431a (diff) | |
download | efl-93ade6f4ce4a336dfcdc748a09dd35003591978b.tar.gz |
Eo base: clean up parent removal in destructor.
This cleans up the changes in 8689d54471aafdd7a5b5a27ce116bf2ab68c1042.
This commit reduces code duplication, and fixes broken handling of
overridden parent_set().
-rw-r--r-- | src/lib/eo/eo_base_class.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index ff62cdae34..0c5f3ef01d 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -986,15 +986,14 @@ _eo_base_destructor(Eo *obj, Eo_Base_Data *pd) child = eina_list_data_get(pd->children); 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; + /* If we have a parent still at the time of destruction, it means that + * ref was already (arguably erroneously unrefed) so we need to ref + * before it gets unrefed again. */ + eo_ref(obj); + eo_do(obj, eo_parent_set(NULL)); } _eo_generic_data_del_all(pd); |