Eo: added back eo_del.

It's needed for proper object hierarchy handling.

SVN revision: 71775
This commit is contained in:
Tom Hacohen 2012-06-07 07:17:45 +00:00
parent e158149868
commit 657aee840e
3 changed files with 26 additions and 2 deletions

View File

@ -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()

View File

@ -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)
{

View File

@ -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));