tasn pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=bc6b6aa457be1325caa5cb86a0a9e166cbb5a7cb

commit bc6b6aa457be1325caa5cb86a0a9e166cbb5a7cb
Author: Tom Hacohen <[email protected]>
Date:   Tue Sep 30 14:27:43 2014 +0100

    Eo: Better define the relationship of eo_add/del/ref/unref.
    
    Now it's more clear and consistent. This commit complements the previous
    eo_add commit (a7560dbc61953c3652780f232e38adbd2d711972).
    
    Now eo_add should be matched with eo_del
    eo_ref with eo_unref
    eo_add_ref with eo_unref + eo_del
    
    Essentially, the change is that if you have the ref to an object, you
    need to unref it. Thus making ref/unref unneeded for most people who use
    things (carefully) in c. If however, you would like to delete an object
    previously created by you, you should eo_del (counter-part to eo_add).
    
    It's still recommended you ref/unref when dealing with objects in
    scopes, as you can't know when an object might just get deleted as a
    by-product of another call.
    
    This fixes an issue found by JackDanielZ.
---
 src/lib/eo/eo.c         |  9 ++++++++-
 src/lib/eo/eo_private.h | 10 ----------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index fa64ce1..e78b6f0 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -1546,7 +1546,14 @@ eo_unref(const Eo *obj_id)
 EAPI void
 eo_del(const Eo *obj)
 {
-   eo_unref(obj);
+   if (eo_do(obj, eo_parent_get()))
+     {
+        eo_do(obj, eo_parent_set(NULL));
+     }
+   else
+     {
+        eo_unref(obj);
+     }
 }
 
 EAPI int
diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h
index 1c21d22..be0a03a 100644
--- a/src/lib/eo/eo_private.h
+++ b/src/lib/eo/eo_private.h
@@ -284,16 +284,6 @@ _eo_unref(_Eo_Object *obj)
              return;
           }
 
-        /* Unparent if parented. */
-          {
-             Eo *eo_id = _eo_id_get(obj);
-             obj->refcount = 2; /* Needs to be high enough that parent set to 
null won't delete the object. */
-
-             eo_do(eo_id, eo_parent_set(NULL));
-
-             obj->refcount = 0;
-          }
-
         _eo_del_internal(__FILE__, __LINE__, obj);
 
 #ifdef EO_DEBUG

-- 


Reply via email to