On 28/09/14 08:54, Daniel Zaoui wrote:
> On 09/25/14 19:49, Tom Hacohen wrote:
>> I know it sounds intrusive, but it's actually more intrusive than it
>> sounds. :P
>>
>> Please keep an eye out for widgets leaking references, or errors in the
>> terminal. Things seem to be sane here, but one can never know.
>>
>> If you see a break, please don't blindly revert these changes, and
>> instead help me find and fix it.
>>
>> Thanks.
>>
>> --
>> Tom.
>>
>> On 25/09/14 17:39, Tom Hacohen wrote:
>>> tasn pushed a commit to branch master.
>>>
>>> http://git.enlightenment.org/core/efl.git/commit/?id=a7560dbc61953c3652780f232e38adbd2d711972
>>>
>>> commit a7560dbc61953c3652780f232e38adbd2d711972
>>> Author: Tom Hacohen <[email protected]>
>>> Date:   Thu Sep 25 15:51:17 2014 +0100
>>>
>>>       Eo: Change eo_add/del/unref behaviour.
>>>
>>>       Before this change eo_add() used to create an object with 1 ref, and 
>>> if
>>>       the object had a parent, a second ref.
>>>       Now, eo_add() always returns an object with 1 ref, and eo_add_ref()
>>>           preserves the old behaviour (for bindings).
>>>
>>>       eo_unref now un-parents if refcount is 0, and eo_del() is an alias for
>>>       eo_unref (will change to be a way to ensure an object is dead and goes
>>>               to zombie-land even if still refed).
>>> ---
>>>    src/lib/ecore/ecore_anim.c                         |  2 --
>>>    src/lib/ecore/ecore_idle_enterer.c                 |  2 --
>>>    src/lib/ecore/ecore_idle_exiter.c                  |  1 -
>>>    src/lib/ecore/ecore_idler.c                        |  1 -
>>>    src/lib/ecore/ecore_job.c                          |  1 -
>>>    src/lib/ecore/ecore_poller.c                       |  1 -
>>>    src/lib/ecore/ecore_timer.c                        |  2 --
>>>    src/lib/edje/edje_edit.c                           |  1 -
>>>    src/lib/edje/edje_smart.c                          |  1 -
>>>    src/lib/emotion/emotion_smart.c                    |  1 -
>>>    src/lib/eo/Eo.h                                    | 26 
>>> ++++++++++++++++++++++
>>>    src/lib/eo/eo.c                                    | 17 +++++++++-----
>>>    src/lib/eo/eo_private.h                            | 11 +++++++++
>>>    src/lib/evas/canvas/evas_3d_camera.c               |  1 -
>>>    src/lib/evas/canvas/evas_3d_light.c                |  1 -
>>>    src/lib/evas/canvas/evas_3d_material.c             |  1 -
>>>    src/lib/evas/canvas/evas_3d_mesh.c                 |  1 -
>>>    src/lib/evas/canvas/evas_3d_node.c                 |  1 -
>>>    src/lib/evas/canvas/evas_3d_scene.c                |  1 -
>>>    src/lib/evas/canvas/evas_3d_texture.c              |  1 -
>>>    src/lib/evas/canvas/evas_object_box.c              |  1 -
>>>    src/lib/evas/canvas/evas_object_grid.c             |  1 -
>>>    src/lib/evas/canvas/evas_object_image.c            |  1 -
>>>    src/lib/evas/canvas/evas_object_line.c             |  1 -
>>>    src/lib/evas/canvas/evas_object_main.c             |  3 +--
>>>    src/lib/evas/canvas/evas_object_polygon.c          |  1 -
>>>    src/lib/evas/canvas/evas_object_rectangle.c        |  1 -
>>>    src/lib/evas/canvas/evas_object_smart.c            |  1 -
>>>    src/lib/evas/canvas/evas_object_table.c            |  1 -
>>>    src/lib/evas/canvas/evas_object_text.c             |  1 -
>>>    src/lib/evas/canvas/evas_object_textblock.c        |  1 -
>>>    src/lib/evas/canvas/evas_object_textgrid.c         |  1 -
>>>    src/lib/evas/canvas/evas_out.c                     |  1 -
>>>    src/tests/eo/children/children_simple.c            |  2 +-
>>>    .../eo/composite_objects/composite_objects_comp.c  |  2 --
>>>    src/tests/eo/suite/eo_test_general.c               | 12 +++++++++-
>>>    36 files changed, 61 insertions(+), 44 deletions(-)
>>>
>>> diff --git a/src/lib/ecore/ecore_anim.c b/src/lib/ecore/ecore_anim.c
>>> index 7116538..6dee5ad 100644
>>> --- a/src/lib/ecore/ecore_anim.c
>>> +++ b/src/lib/ecore/ecore_anim.c
>>> @@ -204,7 +204,6 @@ ecore_animator_add(Ecore_Task_Cb func,
>>>
>>>       animator = eo_add(MY_CLASS, _ecore_parent,
>>>                                ecore_animator_constructor(func, data));
>>> -   eo_unref(animator);
>>>       return animator;
>>>    }
>>>
>>> @@ -224,7 +223,6 @@ ecore_animator_timeline_add(double            runtime,
>>>       Ecore_Animator *animator;
>>>       animator = eo_add(MY_CLASS, _ecore_parent,
>>>                                ecore_animator_timeline_constructor(runtime, 
>>> func, data));
>>> -   eo_unref(animator);
>>>       return animator;
>>>    }
>>>
>>> diff --git a/src/lib/ecore/ecore_idle_enterer.c 
>>> b/src/lib/ecore/ecore_idle_enterer.c
>>> index f6d5b99..038b5c9 100644
>>> --- a/src/lib/ecore/ecore_idle_enterer.c
>>> +++ b/src/lib/ecore/ecore_idle_enterer.c
>>> @@ -64,7 +64,6 @@ ecore_idle_enterer_add(Ecore_Task_Cb func,
>>>    {
>>>       Ecore_Idle_Enterer *ie = NULL;
>>>       ie = eo_add(MY_CLASS, _ecore_parent, 
>>> ecore_idle_enterer_after_constructor(func, data));
>>> -   eo_unref(ie);
>>>       return ie;
>>>    }
>>>
>>> @@ -86,7 +85,6 @@ ecore_idle_enterer_before_add(Ecore_Task_Cb func,
>>>    {
>>>       Ecore_Idle_Enterer *ie = NULL;
>>>       ie = eo_add(MY_CLASS, _ecore_parent, 
>>> ecore_idle_enterer_before_constructor(func, data));
>>> -   eo_unref(ie);
>>>       return ie;
>>>    }
>>>
>>> diff --git a/src/lib/ecore/ecore_idle_exiter.c 
>>> b/src/lib/ecore/ecore_idle_exiter.c
>>> index 51c7d35..b755fc7 100644
>>> --- a/src/lib/ecore/ecore_idle_exiter.c
>>> +++ b/src/lib/ecore/ecore_idle_exiter.c
>>> @@ -38,7 +38,6 @@ ecore_idle_exiter_add(Ecore_Task_Cb func,
>>>    {
>>>       Ecore_Idle_Exiter *ie = NULL;
>>>       ie = eo_add(MY_CLASS, _ecore_parent, 
>>> ecore_idle_exiter_constructor(func, data));
>>> -   eo_unref(ie);
>>>       return ie;
>>>    }
>>>
>>> diff --git a/src/lib/ecore/ecore_idler.c b/src/lib/ecore/ecore_idler.c
>>> index 0ac1bc6..5faed54 100644
>>> --- a/src/lib/ecore/ecore_idler.c
>>> +++ b/src/lib/ecore/ecore_idler.c
>>> @@ -40,7 +40,6 @@ ecore_idler_add(Ecore_Task_Cb func,
>>>       _ecore_lock();
>>>
>>>       ie = eo_add(MY_CLASS, _ecore_parent, ecore_idler_constructor(func, 
>>> data));
>>> -   eo_unref(ie);
>>>
>>>       _ecore_unlock();
>>>       return ie;
>>> diff --git a/src/lib/ecore/ecore_job.c b/src/lib/ecore/ecore_job.c
>>> index ef2b9c0..b148f56 100644
>>> --- a/src/lib/ecore/ecore_job.c
>>> +++ b/src/lib/ecore/ecore_job.c
>>> @@ -50,7 +50,6 @@ ecore_job_add(Ecore_Cb    func,
>>>                  const void *data)
>>>    {
>>>       Ecore_Job *job = eo_add(MY_CLASS, _ecore_parent, 
>>> ecore_job_constructor(func, data));
>>> -   eo_unref(job);
>>>       return job;
>>>    }
>>>
>>> diff --git a/src/lib/ecore/ecore_poller.c b/src/lib/ecore/ecore_poller.c
>>> index e7fca87..61fb768 100644
>>> --- a/src/lib/ecore/ecore_poller.c
>>> +++ b/src/lib/ecore/ecore_poller.c
>>> @@ -239,7 +239,6 @@ ecore_poller_add(Ecore_Poller_Type type EINA_UNUSED,
>>>       Ecore_Poller *poller;
>>>       poller = eo_add(MY_CLASS, _ecore_parent,
>>>                              ecore_poller_constructor(type, interval, func, 
>>> data));
>>> -   eo_unref(poller);
>>>       return poller;
>>>    }
>>>
>>> diff --git a/src/lib/ecore/ecore_timer.c b/src/lib/ecore/ecore_timer.c
>>> index e2cb43b..9d20d27 100644
>>> --- a/src/lib/ecore/ecore_timer.c
>>> +++ b/src/lib/ecore/ecore_timer.c
>>> @@ -98,7 +98,6 @@ ecore_timer_add(double        in,
>>>
>>>       EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
>>>       timer = eo_add(MY_CLASS, _ecore_parent, 
>>> ecore_obj_timer_constructor(in, func, data));
>>> -   eo_unref(timer);
>>>       return timer;
>>>    }
>>>
>>> @@ -400,7 +399,6 @@ _ecore_timer_loop_add(double        in,
>>>    {
>>>       Ecore_Timer *timer = NULL;
>>>       timer = eo_add(MY_CLASS, _ecore_parent, 
>>> ecore_obj_timer_loop_constructor(in, func, data));
>>> -   eo_unref(timer);
>>>
>>>       return timer;
>>>    }
>>> diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
>>> index f51e229..532c6e5 100644
>>> --- a/src/lib/edje/edje_edit.c
>>> +++ b/src/lib/edje/edje_edit.c
>>> @@ -237,7 +237,6 @@ edje_edit_object_add(Evas *evas)
>>>    {
>>>       Evas_Object *e;
>>>       e = eo_add(MY_CLASS, evas);
>>> -   eo_unref(e);
>>>       return e;
>>>    }
>>>
>>> diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c
>>> index 5974b66..a077a96 100644
>>> --- a/src/lib/edje/edje_smart.c
>>> +++ b/src/lib/edje/edje_smart.c
>>> @@ -20,7 +20,6 @@ edje_object_add(Evas *evas)
>>>    {
>>>       Evas_Object *e;
>>>       e = eo_add(MY_CLASS, evas);
>>> -   eo_unref(e);
>>>       return e;
>>>    }
>>>
>>> diff --git a/src/lib/emotion/emotion_smart.c 
>>> b/src/lib/emotion/emotion_smart.c
>>> index b1ea284..9082570 100644
>>> --- a/src/lib/emotion/emotion_smart.c
>>> +++ b/src/lib/emotion/emotion_smart.c
>>> @@ -260,7 +260,6 @@ emotion_object_add(Evas *evas)
>>>    {
>>>       Evas_Object *e;
>>>       e = eo_add(MY_CLASS, evas);
>>> -   eo_unref(e);
>>>       return e;
>>>    }
>>>
>>> diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
>>> index 561665b..b280797 100644
>>> --- a/src/lib/eo/Eo.h
>>> +++ b/src/lib/eo/Eo.h
>>> @@ -621,6 +621,13 @@ EAPI void eo_error_set_internal(const Eo *obj, const 
>>> char *file, int line);
>>>    /**
>>>     * @def eo_add
>>>     * @brief Create a new object with the default constructor.
>>> + *
>>> + * The object returned by this function always has at least 1 ref. If the 
>>> object
>>> + * has a parent, it returns with 1 ref, and even if it doesn't have a 
>>> parent
>>> + * it's returned with 1 ref. This is convenient in C.
>>> + *
>>> + * If you want a more "consistent" behaviour, take a look at #eo_add_ref.
>>> + *
>>>     * @param klass the class of the object to create.
>>>     * @param parent the parent to set to the object.
>>>     * @param ... The ops to run.
>>> @@ -638,6 +645,25 @@ EAPI void eo_error_set_internal(const Eo *obj, const 
>>> char *file, int line);
>>>        _tmp_obj; \
>>>        })
>>>
>>> +/**
>>> + * @def eo_add_ref
>>> + * @brief Create a new object with the default constructor.
>>> + *
>>> + * The object returned by this function has 1 ref for itself, 1 ref from 
>>> the
>>> + * parent (if exists) and possible other refs if were added during 
>>> construction.
>>> + *
>>> + * @param klass the class of the object to create.
>>> + * @param parent the parent to set to the object.
>>> + * @param ... The ops to run.
>>> + * @return An handle to the new object on success, NULL otherwise.
>>> + */
>>> +#define eo_add_ref(klass, parent, ...) \
>>> +   ({ \
>>> +    Eo *_tmp_obj_ref = eo_add(klass, parent, __VA_ARGS__); \
>>> +    if (eo_do(_tmp_obj_ref, eo_parent_get())) eo_ref(_tmp_obj_ref); \
>>> +    _tmp_obj_ref; \
>>> +    })
>>> +
>>>    EAPI Eo * _eo_add_internal_start(const char *file, int line, const 
>>> Eo_Class *klass_id, Eo *parent);
>>>
>>>    /**
>>> diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
>>> index b6c6efa..fa64ce1 100644
>>> --- a/src/lib/eo/eo.c
>>> +++ b/src/lib/eo/eo.c
>>> @@ -904,16 +904,23 @@ _eo_add_internal_start(const char *file, int line, 
>>> const Eo_Class *klass_id, Eo
>>>    #ifndef HAVE_EO_ID
>>>       EINA_MAGIC_SET((Eo_Base *) obj, EO_EINA_MAGIC);
>>>    #endif
>>> -   Eo_Id eo_id = _eo_id_allocate(obj);
>>> -   obj->header.id = eo_id;
>>> +   obj->header.id = _eo_id_allocate(obj);
>>> +   Eo *eo_id = _eo_id_get(obj);
>>>
>>>       _eo_condtor_reset(obj);
>>>
>>>       _eo_ref(obj);
>>>
>>> -   eo_do(_eo_id_get(obj), eo_parent_set(parent_id));
>>> +   eo_do(eo_id, eo_parent_set(parent_id));
>>>
>>> -   return _eo_id_get(obj);
>>> +   /* If there's a parent. Unref. Eo_add should return an object with 
>>> either a
>>> +    * parent ref, or with the lack of, just a ref. */
>>> +   if (eo_do(eo_id, eo_parent_get()))
>>> +     {
>>> +        _eo_unref(obj);
>>> +     }
>>> +
>>> +   return eo_id;
>>>    }
>>>
>>>    Eo *
>>> @@ -1539,8 +1546,6 @@ eo_unref(const Eo *obj_id)
>>>    EAPI void
>>>    eo_del(const Eo *obj)
>>>    {
>>> -   EO_OBJ_POINTER_RETURN(obj, _obj);
>>> -   eo_do((Eo *) obj, eo_parent_set(NULL));
>>>       eo_unref(obj);
>>>    }
>>>
>>> diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h
>>> index c7b6348..1c21d22 100644
>>> --- a/src/lib/eo/eo_private.h
>>> +++ b/src/lib/eo/eo_private.h
>>> @@ -1,6 +1,7 @@
>>>    #ifndef _EO_PRIVATE_H
>>>    #define _EO_PRIVATE_H
>>>
>>> +#include <Eo.h>
>>>    #include <Eina.h>
>>>
>>>    #define EO_EINA_MAGIC 0xa186bc32
>>> @@ -283,6 +284,16 @@ _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
>>> diff --git a/src/lib/evas/canvas/evas_3d_camera.c 
>>> b/src/lib/evas/canvas/evas_3d_camera.c
>>> index 896d563..08a8ab6 100644
>>> --- a/src/lib/evas/canvas/evas_3d_camera.c
>>> +++ b/src/lib/evas/canvas/evas_3d_camera.c
>>> @@ -85,7 +85,6 @@ evas_3d_camera_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(MY_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_3d_light.c 
>>> b/src/lib/evas/canvas/evas_3d_light.c
>>> index 9f6b3c7..74718b2 100644
>>> --- a/src/lib/evas/canvas/evas_3d_light.c
>>> +++ b/src/lib/evas/canvas/evas_3d_light.c
>>> @@ -73,7 +73,6 @@ evas_3d_light_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(MY_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_3d_material.c 
>>> b/src/lib/evas/canvas/evas_3d_material.c
>>> index 1391ed3..8736403 100644
>>> --- a/src/lib/evas/canvas/evas_3d_material.c
>>> +++ b/src/lib/evas/canvas/evas_3d_material.c
>>> @@ -85,7 +85,6 @@ evas_3d_material_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(MY_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_3d_mesh.c 
>>> b/src/lib/evas/canvas/evas_3d_mesh.c
>>> index bc19481..2cbf852 100644
>>> --- a/src/lib/evas/canvas/evas_3d_mesh.c
>>> +++ b/src/lib/evas/canvas/evas_3d_mesh.c
>>> @@ -242,7 +242,6 @@ evas_3d_mesh_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(MY_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_3d_node.c 
>>> b/src/lib/evas/canvas/evas_3d_node.c
>>> index 25c01a7..c7f3604 100644
>>> --- a/src/lib/evas/canvas/evas_3d_node.c
>>> +++ b/src/lib/evas/canvas/evas_3d_node.c
>>> @@ -776,7 +776,6 @@ evas_3d_node_add(Evas *e, Evas_3D_Node_Type type)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(MY_CLASS, e, 
>>> evas_3d_node_constructor(type));
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_3d_scene.c 
>>> b/src/lib/evas/canvas/evas_3d_scene.c
>>> index 42f620f..6db897e 100644
>>> --- a/src/lib/evas/canvas/evas_3d_scene.c
>>> +++ b/src/lib/evas/canvas/evas_3d_scene.c
>>> @@ -55,7 +55,6 @@ evas_3d_scene_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(MY_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_3d_texture.c 
>>> b/src/lib/evas/canvas/evas_3d_texture.c
>>> index 94e537b..6d34591 100644
>>> --- a/src/lib/evas/canvas/evas_3d_texture.c
>>> +++ b/src/lib/evas/canvas/evas_3d_texture.c
>>> @@ -299,7 +299,6 @@ evas_3d_texture_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(MY_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_object_box.c 
>>> b/src/lib/evas/canvas/evas_object_box.c
>>> index b28eff4..f4148bc 100644
>>> --- a/src/lib/evas/canvas/evas_object_box.c
>>> +++ b/src/lib/evas/canvas/evas_object_box.c
>>> @@ -456,7 +456,6 @@ EAPI Evas_Object *
>>>    evas_object_box_add(Evas *evas)
>>>    {
>>>       Evas_Object *obj = eo_add(MY_CLASS, evas);
>>> -   eo_unref(obj);
>>>       return obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_object_grid.c 
>>> b/src/lib/evas/canvas/evas_object_grid.c
>>> index 8d153cd..3e61201 100644
>>> --- a/src/lib/evas/canvas/evas_object_grid.c
>>> +++ b/src/lib/evas/canvas/evas_object_grid.c
>>> @@ -258,7 +258,6 @@ EAPI Evas_Object *
>>>    evas_object_grid_add(Evas *evas)
>>>    {
>>>       Evas_Object *obj = eo_add(MY_CLASS, evas);
>>> -   eo_unref(obj);
>>>       return obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_object_image.c 
>>> b/src/lib/evas/canvas/evas_object_image.c
>>> index ea8fc8a..6cdb965 100644
>>> --- a/src/lib/evas/canvas/evas_object_image.c
>>> +++ b/src/lib/evas/canvas/evas_object_image.c
>>> @@ -381,7 +381,6 @@ evas_object_image_add(Evas *eo_e)
>>>       EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
>>>       EINA_SAFETY_ON_NULL_RETURN_VAL(e->engine.func, NULL);
>>>       Evas_Object *eo_obj = eo_add(EVAS_IMAGE_CLASS, eo_e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_object_line.c 
>>> b/src/lib/evas/canvas/evas_object_line.c
>>> index 48db646..4c2d789 100644
>>> --- a/src/lib/evas/canvas/evas_object_line.c
>>> +++ b/src/lib/evas/canvas/evas_object_line.c
>>> @@ -97,7 +97,6 @@ evas_object_line_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(EVAS_LINE_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_object_main.c 
>>> b/src/lib/evas/canvas/evas_object_main.c
>>> index 29706fa..162b1f3 100644
>>> --- a/src/lib/evas/canvas/evas_object_main.c
>>> +++ b/src/lib/evas/canvas/evas_object_main.c
>>> @@ -621,8 +621,7 @@ evas_object_del(Evas_Object *eo_obj)
>>>
>>>       obj->eo_del_called = EINA_TRUE;
>>>
>>> -   eo_do(eo_obj, eo_parent_set(NULL));
>>> -//   eo_del(eo_obj);
>>> +   eo_del(eo_obj);
>>>    }
>>>
>>>    EOLIAN static void
>>> diff --git a/src/lib/evas/canvas/evas_object_polygon.c 
>>> b/src/lib/evas/canvas/evas_object_polygon.c
>>> index 53d8316..cd27199 100644
>>> --- a/src/lib/evas/canvas/evas_object_polygon.c
>>> +++ b/src/lib/evas/canvas/evas_object_polygon.c
>>> @@ -98,7 +98,6 @@ evas_object_polygon_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(EVAS_POLYGON_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_object_rectangle.c 
>>> b/src/lib/evas/canvas/evas_object_rectangle.c
>>> index aa11425..3633bc0 100644
>>> --- a/src/lib/evas/canvas/evas_object_rectangle.c
>>> +++ b/src/lib/evas/canvas/evas_object_rectangle.c
>>> @@ -86,7 +86,6 @@ evas_object_rectangle_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(EVAS_RECTANGLE_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_object_smart.c 
>>> b/src/lib/evas/canvas/evas_object_smart.c
>>> index 42da500..73b078d 100644
>>> --- a/src/lib/evas/canvas/evas_object_smart.c
>>> +++ b/src/lib/evas/canvas/evas_object_smart.c
>>> @@ -536,7 +536,6 @@ evas_object_smart_add(Evas *eo_e, Evas_Smart *s)
>>>       MAGIC_CHECK_END();
>>>       eo_obj = eo_add(EVAS_OBJECT_SMART_CLASS, eo_e);
>>>       eo_do(eo_obj, evas_obj_smart_attach(s));
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_object_table.c 
>>> b/src/lib/evas/canvas/evas_object_table.c
>>> index a9259a8..99cd84a 100644
>>> --- a/src/lib/evas/canvas/evas_object_table.c
>>> +++ b/src/lib/evas/canvas/evas_object_table.c
>>> @@ -960,7 +960,6 @@ EAPI Evas_Object *
>>>    evas_object_table_add(Evas *evas)
>>>    {
>>>       Evas_Object *obj = eo_add(MY_CLASS, evas);
>>> -   eo_unref(obj);
>>>       return obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_object_text.c 
>>> b/src/lib/evas/canvas/evas_object_text.c
>>> index 37a4c56..6a1e1df 100644
>>> --- a/src/lib/evas/canvas/evas_object_text.c
>>> +++ b/src/lib/evas/canvas/evas_object_text.c
>>> @@ -371,7 +371,6 @@ evas_object_text_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(EVAS_TEXT_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_object_textblock.c 
>>> b/src/lib/evas/canvas/evas_object_textblock.c
>>> index e0c286e..520761d 100644
>>> --- a/src/lib/evas/canvas/evas_object_textblock.c
>>> +++ b/src/lib/evas/canvas/evas_object_textblock.c
>>> @@ -5672,7 +5672,6 @@ evas_object_textblock_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(EVAS_TEXTBLOCK_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_object_textgrid.c 
>>> b/src/lib/evas/canvas/evas_object_textgrid.c
>>> index 309efa2..e274201 100644
>>> --- a/src/lib/evas/canvas/evas_object_textgrid.c
>>> +++ b/src/lib/evas/canvas/evas_object_textgrid.c
>>> @@ -1056,7 +1056,6 @@ evas_object_textgrid_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(EVAS_TEXTGRID_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/lib/evas/canvas/evas_out.c b/src/lib/evas/canvas/evas_out.c
>>> index 48a8755..27f459e 100644
>>> --- a/src/lib/evas/canvas/evas_out.c
>>> +++ b/src/lib/evas/canvas/evas_out.c
>>> @@ -20,7 +20,6 @@ evas_out_add(Evas *e)
>>>       return NULL;
>>>       MAGIC_CHECK_END();
>>>       Evas_Object *eo_obj = eo_add(MY_CLASS, e);
>>> -   eo_unref(eo_obj);
>>>       return eo_obj;
>>>    }
>>>
>>> diff --git a/src/tests/eo/children/children_simple.c 
>>> b/src/tests/eo/children/children_simple.c
>>> index cd351d3..a85767c 100644
>>> --- a/src/tests/eo/children/children_simple.c
>>> +++ b/src/tests/eo/children/children_simple.c
>>> @@ -18,5 +18,5 @@ static const Eo_Class_Description class_desc = {
>>>         NULL
>>>    };
>>>
>>> -EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL)
>>> +EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL)
>>>
>>> diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c 
>>> b/src/tests/eo/composite_objects/composite_objects_comp.c
>>> index d880c98..17cd95c 100644
>>> --- a/src/tests/eo/composite_objects/composite_objects_comp.c
>>> +++ b/src/tests/eo/composite_objects/composite_objects_comp.c
>>> @@ -32,8 +32,6 @@ _constructor(Eo *obj, void *class_data EINA_UNUSED)
>>>       fail_if(!eo_composite_is(simple));
>>>
>>>       eo_do(obj, eo_key_data_set("simple-obj", simple, NULL));
>>> -
>>> -   eo_unref(simple);
>>>    }
>>>
>>>    static Eo_Op_Description op_descs[] = {
>>> diff --git a/src/tests/eo/suite/eo_test_general.c 
>>> b/src/tests/eo/suite/eo_test_general.c
>>> index 114d244..77fca9c 100644
>>> --- a/src/tests/eo/suite/eo_test_general.c
>>> +++ b/src/tests/eo/suite/eo_test_general.c
>>> @@ -435,7 +435,7 @@ START_TEST(eo_refs)
>>>
>>>       /* Check hierarchy */
>>>       obj = eo_add(SIMPLE_CLASS, NULL);
>>> -   obj2 = eo_add(SIMPLE_CLASS, obj);
>>> +   obj2 = eo_ref(eo_add(SIMPLE_CLASS, obj));
>>>
>>>       Eo *wref = NULL;
>>>       eo_do(obj2, eo_wref_add(&wref));
>>> @@ -449,6 +449,16 @@ START_TEST(eo_refs)
>>>
>>>       fail_if(wref);
>>>
>>> +   /* eo_add_ref and normal eo_add */
>>> +   obj = eo_add(SIMPLE_CLASS, NULL);
>>> +   obj2 = eo_add(SIMPLE_CLASS, obj);
>>> +   obj3 = eo_add_ref(SIMPLE_CLASS, obj);
>>> +
>>> +   ck_assert_int_eq(eo_ref_get(obj), 1);
>>> +   ck_assert_int_eq(eo_ref_get(obj2), 1);
>>> +   ck_assert_int_eq(eo_ref_get(obj3), 2);
>>> +
>>> +
>>>       /* Just check it doesn't seg atm. */
>>>       obj = eo_add(SIMPLE_CLASS, NULL);
>>>       eo_ref(obj);
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
>> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
>> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
>> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
>> _______________________________________________
>> enlightenment-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>>
>
> By the way, why do you need so many unrefs inside Eo?
>
> Why this (http://pastebin.com/KFHxXAXn) cannot work? Well it works, but
> does it remove specific cases coverage, like protect from object
> deletion until finalize?
>

First reason is "correctness". If you want to handle an object, you need 
to get a ref for it. The second reason is that an object can actually be 
deleted inside the constructor, or many similar things, and you want to 
keep a ref to make sure it's not deleted underneath your feet.

-- 
Tom.


------------------------------------------------------------------------------
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to