From 657aee840ed64ad08e84093c8d050d3f6c746507 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Jun 2012 07:17:45 +0000 Subject: [PATCH] Eo: added back eo_del. It's needed for proper object hierarchy handling. SVN revision: 71775 --- legacy/eobj/lib/Eo.h | 9 +++++++++ legacy/eobj/lib/eo.c | 11 +++++++++-- legacy/eobj/tests/eo_test_general.c | 8 ++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/legacy/eobj/lib/Eo.h b/legacy/eobj/lib/Eo.h index bdce552d48..db7d691b51 100644 --- a/legacy/eobj/lib/Eo.h +++ b/legacy/eobj/lib/Eo.h @@ -720,6 +720,15 @@ EAPI void eo_unref(const Eo *obj); */ EAPI int eo_ref_get(const Eo *obj); +/** + * @brief Unrefs the object and reparents it to NULL. + * @param obj the object to work on. + * + * @see eo_unref() + * @see eo_parent_set() + */ +EAPI void eo_del(const Eo *obj); + /** * @def eo_xref(obj, ref_obj) * Convenience macro around eo_xref_internal() diff --git a/legacy/eobj/lib/eo.c b/legacy/eobj/lib/eo.c index f727da15ec..8a4baeb989 100644 --- a/legacy/eobj/lib/eo.c +++ b/legacy/eobj/lib/eo.c @@ -1078,7 +1078,7 @@ eo_parent_set(Eo *obj, const Eo *parent) { obj->parent->children = eina_inlist_remove(obj->parent->children, EINA_INLIST_GET(obj)); -// eo_xunref(obj, obj->parent); + eo_xunref(obj, obj->parent); } obj->parent = (Eo *) parent; @@ -1086,7 +1086,7 @@ eo_parent_set(Eo *obj, const Eo *parent) { obj->parent->children = eina_inlist_append(obj->parent->children, EINA_INLIST_GET(obj)); -// eo_xref(obj, obj->parent); + eo_xref(obj, obj->parent); } _eo_unref(obj); @@ -1309,6 +1309,13 @@ eo_unref(const Eo *_obj) _eo_unref(obj); } +EAPI void +eo_del(const Eo *obj) +{ + eo_parent_set((Eo *) obj, NULL); + eo_unref(obj); +} + EAPI int eo_ref_get(const Eo *obj) { diff --git a/legacy/eobj/tests/eo_test_general.c b/legacy/eobj/tests/eo_test_general.c index 7b260623ea..f9311e0929 100644 --- a/legacy/eobj/tests/eo_test_general.c +++ b/legacy/eobj/tests/eo_test_general.c @@ -206,6 +206,13 @@ START_TEST(eo_refs) eo_unref(obj); eo_unref(obj); + obj = eo_add(SIMPLE_CLASS, NULL); + obj2 = eo_add(SIMPLE_CLASS, obj); + eo_unref(obj2); + eo_ref(obj2); + eo_del(obj2); + eo_unref(obj); + eo_shutdown(); } END_TEST @@ -457,6 +464,7 @@ START_TEST(eo_magic_checks) eo_ref((Eo *) buf); eo_unref((Eo *) buf); + eo_del((Eo *) buf); fail_if(0 != eo_ref_get((Eo *) buf));