summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2014-09-25 15:51:17 +0100
committerTom Hacohen <tom@stosb.com>2014-09-25 17:38:45 +0100
commita7560dbc61953c3652780f232e38adbd2d711972 (patch)
tree5883eada4cad354a8e16cbacbad0b24660884fcf
parent2bc462f55b2e0d0b4bee6998f91b611be4ee1d2d (diff)
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).
-rw-r--r--src/lib/ecore/ecore_anim.c2
-rw-r--r--src/lib/ecore/ecore_idle_enterer.c2
-rw-r--r--src/lib/ecore/ecore_idle_exiter.c1
-rw-r--r--src/lib/ecore/ecore_idler.c1
-rw-r--r--src/lib/ecore/ecore_job.c1
-rw-r--r--src/lib/ecore/ecore_poller.c1
-rw-r--r--src/lib/ecore/ecore_timer.c2
-rw-r--r--src/lib/edje/edje_edit.c1
-rw-r--r--src/lib/edje/edje_smart.c1
-rw-r--r--src/lib/emotion/emotion_smart.c1
-rw-r--r--src/lib/eo/Eo.h26
-rw-r--r--src/lib/eo/eo.c17
-rw-r--r--src/lib/eo/eo_private.h11
-rw-r--r--src/lib/evas/canvas/evas_3d_camera.c1
-rw-r--r--src/lib/evas/canvas/evas_3d_light.c1
-rw-r--r--src/lib/evas/canvas/evas_3d_material.c1
-rw-r--r--src/lib/evas/canvas/evas_3d_mesh.c1
-rw-r--r--src/lib/evas/canvas/evas_3d_node.c1
-rw-r--r--src/lib/evas/canvas/evas_3d_scene.c1
-rw-r--r--src/lib/evas/canvas/evas_3d_texture.c1
-rw-r--r--src/lib/evas/canvas/evas_object_box.c1
-rw-r--r--src/lib/evas/canvas/evas_object_grid.c1
-rw-r--r--src/lib/evas/canvas/evas_object_image.c1
-rw-r--r--src/lib/evas/canvas/evas_object_line.c1
-rw-r--r--src/lib/evas/canvas/evas_object_main.c3
-rw-r--r--src/lib/evas/canvas/evas_object_polygon.c1
-rw-r--r--src/lib/evas/canvas/evas_object_rectangle.c1
-rw-r--r--src/lib/evas/canvas/evas_object_smart.c1
-rw-r--r--src/lib/evas/canvas/evas_object_table.c1
-rw-r--r--src/lib/evas/canvas/evas_object_text.c1
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c1
-rw-r--r--src/lib/evas/canvas/evas_object_textgrid.c1
-rw-r--r--src/lib/evas/canvas/evas_out.c1
-rw-r--r--src/tests/eo/children/children_simple.c2
-rw-r--r--src/tests/eo/composite_objects/composite_objects_comp.c2
-rw-r--r--src/tests/eo/suite/eo_test_general.c12
36 files changed, 61 insertions, 44 deletions
diff --git a/src/lib/ecore/ecore_anim.c b/src/lib/ecore/ecore_anim.c
index 7116538b7d..6dee5ad0b4 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,
204 204
205 animator = eo_add(MY_CLASS, _ecore_parent, 205 animator = eo_add(MY_CLASS, _ecore_parent,
206 ecore_animator_constructor(func, data)); 206 ecore_animator_constructor(func, data));
207 eo_unref(animator);
208 return animator; 207 return animator;
209} 208}
210 209
@@ -224,7 +223,6 @@ ecore_animator_timeline_add(double runtime,
224 Ecore_Animator *animator; 223 Ecore_Animator *animator;
225 animator = eo_add(MY_CLASS, _ecore_parent, 224 animator = eo_add(MY_CLASS, _ecore_parent,
226 ecore_animator_timeline_constructor(runtime, func, data)); 225 ecore_animator_timeline_constructor(runtime, func, data));
227 eo_unref(animator);
228 return animator; 226 return animator;
229} 227}
230 228
diff --git a/src/lib/ecore/ecore_idle_enterer.c b/src/lib/ecore/ecore_idle_enterer.c
index f6d5b9997d..038b5c9946 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,
64{ 64{
65 Ecore_Idle_Enterer *ie = NULL; 65 Ecore_Idle_Enterer *ie = NULL;
66 ie = eo_add(MY_CLASS, _ecore_parent, ecore_idle_enterer_after_constructor(func, data)); 66 ie = eo_add(MY_CLASS, _ecore_parent, ecore_idle_enterer_after_constructor(func, data));
67 eo_unref(ie);
68 return ie; 67 return ie;
69} 68}
70 69
@@ -86,7 +85,6 @@ ecore_idle_enterer_before_add(Ecore_Task_Cb func,
86{ 85{
87 Ecore_Idle_Enterer *ie = NULL; 86 Ecore_Idle_Enterer *ie = NULL;
88 ie = eo_add(MY_CLASS, _ecore_parent, ecore_idle_enterer_before_constructor(func, data)); 87 ie = eo_add(MY_CLASS, _ecore_parent, ecore_idle_enterer_before_constructor(func, data));
89 eo_unref(ie);
90 return ie; 88 return ie;
91} 89}
92 90
diff --git a/src/lib/ecore/ecore_idle_exiter.c b/src/lib/ecore/ecore_idle_exiter.c
index 51c7d357e4..b755fc702c 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,
38{ 38{
39 Ecore_Idle_Exiter *ie = NULL; 39 Ecore_Idle_Exiter *ie = NULL;
40 ie = eo_add(MY_CLASS, _ecore_parent, ecore_idle_exiter_constructor(func, data)); 40 ie = eo_add(MY_CLASS, _ecore_parent, ecore_idle_exiter_constructor(func, data));
41 eo_unref(ie);
42 return ie; 41 return ie;
43} 42}
44 43
diff --git a/src/lib/ecore/ecore_idler.c b/src/lib/ecore/ecore_idler.c
index 0ac1bc6e72..5faed546fb 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,
40 _ecore_lock(); 40 _ecore_lock();
41 41
42 ie = eo_add(MY_CLASS, _ecore_parent, ecore_idler_constructor(func, data)); 42 ie = eo_add(MY_CLASS, _ecore_parent, ecore_idler_constructor(func, data));
43 eo_unref(ie);
44 43
45 _ecore_unlock(); 44 _ecore_unlock();
46 return ie; 45 return ie;
diff --git a/src/lib/ecore/ecore_job.c b/src/lib/ecore/ecore_job.c
index ef2b9c0660..b148f5682e 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,
50 const void *data) 50 const void *data)
51{ 51{
52 Ecore_Job *job = eo_add(MY_CLASS, _ecore_parent, ecore_job_constructor(func, data)); 52 Ecore_Job *job = eo_add(MY_CLASS, _ecore_parent, ecore_job_constructor(func, data));
53 eo_unref(job);
54 return job; 53 return job;
55} 54}
56 55
diff --git a/src/lib/ecore/ecore_poller.c b/src/lib/ecore/ecore_poller.c
index e7fca873db..61fb7684e3 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,
239 Ecore_Poller *poller; 239 Ecore_Poller *poller;
240 poller = eo_add(MY_CLASS, _ecore_parent, 240 poller = eo_add(MY_CLASS, _ecore_parent,
241 ecore_poller_constructor(type, interval, func, data)); 241 ecore_poller_constructor(type, interval, func, data));
242 eo_unref(poller);
243 return poller; 242 return poller;
244} 243}
245 244
diff --git a/src/lib/ecore/ecore_timer.c b/src/lib/ecore/ecore_timer.c
index e2cb43b686..9d20d27685 100644
--- a/src/lib/ecore/ecore_timer.c
+++ b/src/lib/ecore/ecore_timer.c
@@ -98,7 +98,6 @@ ecore_timer_add(double in,
98 98
99 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); 99 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
100 timer = eo_add(MY_CLASS, _ecore_parent, ecore_obj_timer_constructor(in, func, data)); 100 timer = eo_add(MY_CLASS, _ecore_parent, ecore_obj_timer_constructor(in, func, data));
101 eo_unref(timer);
102 return timer; 101 return timer;
103} 102}
104 103
@@ -400,7 +399,6 @@ _ecore_timer_loop_add(double in,
400{ 399{
401 Ecore_Timer *timer = NULL; 400 Ecore_Timer *timer = NULL;
402 timer = eo_add(MY_CLASS, _ecore_parent, ecore_obj_timer_loop_constructor(in, func, data)); 401 timer = eo_add(MY_CLASS, _ecore_parent, ecore_obj_timer_loop_constructor(in, func, data));
403 eo_unref(timer);
404 402
405 return timer; 403 return timer;
406} 404}
diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c
index f51e2299a9..532c6e58ad 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)
237{ 237{
238 Evas_Object *e; 238 Evas_Object *e;
239 e = eo_add(MY_CLASS, evas); 239 e = eo_add(MY_CLASS, evas);
240 eo_unref(e);
241 return e; 240 return e;
242} 241}
243 242
diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c
index 5974b66e1b..a077a96e79 100644
--- a/src/lib/edje/edje_smart.c
+++ b/src/lib/edje/edje_smart.c
@@ -20,7 +20,6 @@ edje_object_add(Evas *evas)
20{ 20{
21 Evas_Object *e; 21 Evas_Object *e;
22 e = eo_add(MY_CLASS, evas); 22 e = eo_add(MY_CLASS, evas);
23 eo_unref(e);
24 return e; 23 return e;
25} 24}
26 25
diff --git a/src/lib/emotion/emotion_smart.c b/src/lib/emotion/emotion_smart.c
index b1ea284d1b..90825702a0 100644
--- a/src/lib/emotion/emotion_smart.c
+++ b/src/lib/emotion/emotion_smart.c
@@ -260,7 +260,6 @@ emotion_object_add(Evas *evas)
260{ 260{
261 Evas_Object *e; 261 Evas_Object *e;
262 e = eo_add(MY_CLASS, evas); 262 e = eo_add(MY_CLASS, evas);
263 eo_unref(e);
264 return e; 263 return e;
265} 264}
266 265
diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h
index 561665bb7b..b2807979bd 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);
621/** 621/**
622 * @def eo_add 622 * @def eo_add
623 * @brief Create a new object with the default constructor. 623 * @brief Create a new object with the default constructor.
624 *
625 * The object returned by this function always has at least 1 ref. If the object
626 * has a parent, it returns with 1 ref, and even if it doesn't have a parent
627 * it's returned with 1 ref. This is convenient in C.
628 *
629 * If you want a more "consistent" behaviour, take a look at #eo_add_ref.
630 *
624 * @param klass the class of the object to create. 631 * @param klass the class of the object to create.
625 * @param parent the parent to set to the object. 632 * @param parent the parent to set to the object.
626 * @param ... The ops to run. 633 * @param ... The ops to run.
@@ -638,6 +645,25 @@ EAPI void eo_error_set_internal(const Eo *obj, const char *file, int line);
638 _tmp_obj; \ 645 _tmp_obj; \
639 }) 646 })
640 647
648/**
649 * @def eo_add_ref
650 * @brief Create a new object with the default constructor.
651 *
652 * The object returned by this function has 1 ref for itself, 1 ref from the
653 * parent (if exists) and possible other refs if were added during construction.
654 *
655 * @param klass the class of the object to create.
656 * @param parent the parent to set to the object.
657 * @param ... The ops to run.
658 * @return An handle to the new object on success, NULL otherwise.
659 */
660#define eo_add_ref(klass, parent, ...) \
661 ({ \
662 Eo *_tmp_obj_ref = eo_add(klass, parent, __VA_ARGS__); \
663 if (eo_do(_tmp_obj_ref, eo_parent_get())) eo_ref(_tmp_obj_ref); \
664 _tmp_obj_ref; \
665 })
666
641EAPI Eo * _eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent); 667EAPI Eo * _eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo *parent);
642 668
643/** 669/**
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index b6c6efa72e..fa64ce135f 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
904#ifndef HAVE_EO_ID 904#ifndef HAVE_EO_ID
905 EINA_MAGIC_SET((Eo_Base *) obj, EO_EINA_MAGIC); 905 EINA_MAGIC_SET((Eo_Base *) obj, EO_EINA_MAGIC);
906#endif 906#endif
907 Eo_Id eo_id = _eo_id_allocate(obj); 907 obj->header.id = _eo_id_allocate(obj);
908 obj->header.id = eo_id; 908 Eo *eo_id = _eo_id_get(obj);
909 909
910 _eo_condtor_reset(obj); 910 _eo_condtor_reset(obj);
911 911
912 _eo_ref(obj); 912 _eo_ref(obj);
913 913
914 eo_do(_eo_id_get(obj), eo_parent_set(parent_id)); 914 eo_do(eo_id, eo_parent_set(parent_id));
915 915
916 return _eo_id_get(obj); 916 /* If there's a parent. Unref. Eo_add should return an object with either a
917 * parent ref, or with the lack of, just a ref. */
918 if (eo_do(eo_id, eo_parent_get()))
919 {
920 _eo_unref(obj);
921 }
922
923 return eo_id;
917} 924}
918 925
919Eo * 926Eo *
@@ -1539,8 +1546,6 @@ eo_unref(const Eo *obj_id)
1539EAPI void 1546EAPI void
1540eo_del(const Eo *obj) 1547eo_del(const Eo *obj)
1541{ 1548{
1542 EO_OBJ_POINTER_RETURN(obj, _obj);
1543 eo_do((Eo *) obj, eo_parent_set(NULL));
1544 eo_unref(obj); 1549 eo_unref(obj);
1545} 1550}
1546 1551
diff --git a/src/lib/eo/eo_private.h b/src/lib/eo/eo_private.h
index c7b6348953..1c21d2255e 100644
--- a/src/lib/eo/eo_private.h
+++ b/src/lib/eo/eo_private.h
@@ -1,6 +1,7 @@
1#ifndef _EO_PRIVATE_H 1#ifndef _EO_PRIVATE_H
2#define _EO_PRIVATE_H 2#define _EO_PRIVATE_H
3 3
4#include <Eo.h>
4#include <Eina.h> 5#include <Eina.h>
5 6
6#define EO_EINA_MAGIC 0xa186bc32 7#define EO_EINA_MAGIC 0xa186bc32
@@ -283,6 +284,16 @@ _eo_unref(_Eo_Object *obj)
283 return; 284 return;
284 } 285 }
285 286
287 /* Unparent if parented. */
288 {
289 Eo *eo_id = _eo_id_get(obj);
290 obj->refcount = 2; /* Needs to be high enough that parent set to null won't delete the object. */
291
292 eo_do(eo_id, eo_parent_set(NULL));
293
294 obj->refcount = 0;
295 }
296
286 _eo_del_internal(__FILE__, __LINE__, obj); 297 _eo_del_internal(__FILE__, __LINE__, obj);
287 298
288#ifdef EO_DEBUG 299#ifdef EO_DEBUG
diff --git a/src/lib/evas/canvas/evas_3d_camera.c b/src/lib/evas/canvas/evas_3d_camera.c
index 896d563bd3..08a8ab6b15 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)
85 return NULL; 85 return NULL;
86 MAGIC_CHECK_END(); 86 MAGIC_CHECK_END();
87 Evas_Object *eo_obj = eo_add(MY_CLASS, e); 87 Evas_Object *eo_obj = eo_add(MY_CLASS, e);
88 eo_unref(eo_obj);
89 return eo_obj; 88 return eo_obj;
90} 89}
91 90
diff --git a/src/lib/evas/canvas/evas_3d_light.c b/src/lib/evas/canvas/evas_3d_light.c
index 9f6b3c73e3..74718b2aa1 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)
73 return NULL; 73 return NULL;
74 MAGIC_CHECK_END(); 74 MAGIC_CHECK_END();
75 Evas_Object *eo_obj = eo_add(MY_CLASS, e); 75 Evas_Object *eo_obj = eo_add(MY_CLASS, e);
76 eo_unref(eo_obj);
77 return eo_obj; 76 return eo_obj;
78} 77}
79 78
diff --git a/src/lib/evas/canvas/evas_3d_material.c b/src/lib/evas/canvas/evas_3d_material.c
index 1391ed3f52..87364037c3 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)
85 return NULL; 85 return NULL;
86 MAGIC_CHECK_END(); 86 MAGIC_CHECK_END();
87 Evas_Object *eo_obj = eo_add(MY_CLASS, e); 87 Evas_Object *eo_obj = eo_add(MY_CLASS, e);
88 eo_unref(eo_obj);
89 return eo_obj; 88 return eo_obj;
90} 89}
91 90
diff --git a/src/lib/evas/canvas/evas_3d_mesh.c b/src/lib/evas/canvas/evas_3d_mesh.c
index bc19481ccb..2cbf852f0d 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)
242 return NULL; 242 return NULL;
243 MAGIC_CHECK_END(); 243 MAGIC_CHECK_END();
244 Evas_Object *eo_obj = eo_add(MY_CLASS, e); 244 Evas_Object *eo_obj = eo_add(MY_CLASS, e);
245 eo_unref(eo_obj);
246 return eo_obj; 245 return eo_obj;
247} 246}
248 247
diff --git a/src/lib/evas/canvas/evas_3d_node.c b/src/lib/evas/canvas/evas_3d_node.c
index 25c01a72b8..c7f3604547 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)
776 return NULL; 776 return NULL;
777 MAGIC_CHECK_END(); 777 MAGIC_CHECK_END();
778 Evas_Object *eo_obj = eo_add(MY_CLASS, e, evas_3d_node_constructor(type)); 778 Evas_Object *eo_obj = eo_add(MY_CLASS, e, evas_3d_node_constructor(type));
779 eo_unref(eo_obj);
780 return eo_obj; 779 return eo_obj;
781} 780}
782 781
diff --git a/src/lib/evas/canvas/evas_3d_scene.c b/src/lib/evas/canvas/evas_3d_scene.c
index 42f620f352..6db897ec39 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)
55 return NULL; 55 return NULL;
56 MAGIC_CHECK_END(); 56 MAGIC_CHECK_END();
57 Evas_Object *eo_obj = eo_add(MY_CLASS, e); 57 Evas_Object *eo_obj = eo_add(MY_CLASS, e);
58 eo_unref(eo_obj);
59 return eo_obj; 58 return eo_obj;
60} 59}
61 60
diff --git a/src/lib/evas/canvas/evas_3d_texture.c b/src/lib/evas/canvas/evas_3d_texture.c
index 94e537b7c9..6d345914f2 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)
299 return NULL; 299 return NULL;
300 MAGIC_CHECK_END(); 300 MAGIC_CHECK_END();
301 Evas_Object *eo_obj = eo_add(MY_CLASS, e); 301 Evas_Object *eo_obj = eo_add(MY_CLASS, e);
302 eo_unref(eo_obj);
303 return eo_obj; 302 return eo_obj;
304} 303}
305 304
diff --git a/src/lib/evas/canvas/evas_object_box.c b/src/lib/evas/canvas/evas_object_box.c
index b28eff4026..f4148bcf35 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 *
456evas_object_box_add(Evas *evas) 456evas_object_box_add(Evas *evas)
457{ 457{
458 Evas_Object *obj = eo_add(MY_CLASS, evas); 458 Evas_Object *obj = eo_add(MY_CLASS, evas);
459 eo_unref(obj);
460 return obj; 459 return obj;
461} 460}
462 461
diff --git a/src/lib/evas/canvas/evas_object_grid.c b/src/lib/evas/canvas/evas_object_grid.c
index 8d153cdbe1..3e612010bb 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 *
258evas_object_grid_add(Evas *evas) 258evas_object_grid_add(Evas *evas)
259{ 259{
260 Evas_Object *obj = eo_add(MY_CLASS, evas); 260 Evas_Object *obj = eo_add(MY_CLASS, evas);
261 eo_unref(obj);
262 return obj; 261 return obj;
263} 262}
264 263
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index ea8fc8a4b6..6cdb965637 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)
381 EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL); 381 EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
382 EINA_SAFETY_ON_NULL_RETURN_VAL(e->engine.func, NULL); 382 EINA_SAFETY_ON_NULL_RETURN_VAL(e->engine.func, NULL);
383 Evas_Object *eo_obj = eo_add(EVAS_IMAGE_CLASS, eo_e); 383 Evas_Object *eo_obj = eo_add(EVAS_IMAGE_CLASS, eo_e);
384 eo_unref(eo_obj);
385 return eo_obj; 384 return eo_obj;
386} 385}
387 386
diff --git a/src/lib/evas/canvas/evas_object_line.c b/src/lib/evas/canvas/evas_object_line.c
index 48db646952..4c2d7891b1 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)
97 return NULL; 97 return NULL;
98 MAGIC_CHECK_END(); 98 MAGIC_CHECK_END();
99 Evas_Object *eo_obj = eo_add(EVAS_LINE_CLASS, e); 99 Evas_Object *eo_obj = eo_add(EVAS_LINE_CLASS, e);
100 eo_unref(eo_obj);
101 return eo_obj; 100 return eo_obj;
102} 101}
103 102
diff --git a/src/lib/evas/canvas/evas_object_main.c b/src/lib/evas/canvas/evas_object_main.c
index 29706fa622..162b1f3daf 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)
621 621
622 obj->eo_del_called = EINA_TRUE; 622 obj->eo_del_called = EINA_TRUE;
623 623
624 eo_do(eo_obj, eo_parent_set(NULL)); 624 eo_del(eo_obj);
625// eo_del(eo_obj);
626} 625}
627 626
628EOLIAN static void 627EOLIAN static void
diff --git a/src/lib/evas/canvas/evas_object_polygon.c b/src/lib/evas/canvas/evas_object_polygon.c
index 53d8316201..cd27199282 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)
98 return NULL; 98 return NULL;
99 MAGIC_CHECK_END(); 99 MAGIC_CHECK_END();
100 Evas_Object *eo_obj = eo_add(EVAS_POLYGON_CLASS, e); 100 Evas_Object *eo_obj = eo_add(EVAS_POLYGON_CLASS, e);
101 eo_unref(eo_obj);
102 return eo_obj; 101 return eo_obj;
103} 102}
104 103
diff --git a/src/lib/evas/canvas/evas_object_rectangle.c b/src/lib/evas/canvas/evas_object_rectangle.c
index aa114258ab..3633bc001a 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)
86 return NULL; 86 return NULL;
87 MAGIC_CHECK_END(); 87 MAGIC_CHECK_END();
88 Evas_Object *eo_obj = eo_add(EVAS_RECTANGLE_CLASS, e); 88 Evas_Object *eo_obj = eo_add(EVAS_RECTANGLE_CLASS, e);
89 eo_unref(eo_obj);
90 return eo_obj; 89 return eo_obj;
91} 90}
92 91
diff --git a/src/lib/evas/canvas/evas_object_smart.c b/src/lib/evas/canvas/evas_object_smart.c
index 42da500947..73b078d466 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)
536 MAGIC_CHECK_END(); 536 MAGIC_CHECK_END();
537 eo_obj = eo_add(EVAS_OBJECT_SMART_CLASS, eo_e); 537 eo_obj = eo_add(EVAS_OBJECT_SMART_CLASS, eo_e);
538 eo_do(eo_obj, evas_obj_smart_attach(s)); 538 eo_do(eo_obj, evas_obj_smart_attach(s));
539 eo_unref(eo_obj);
540 return eo_obj; 539 return eo_obj;
541} 540}
542 541
diff --git a/src/lib/evas/canvas/evas_object_table.c b/src/lib/evas/canvas/evas_object_table.c
index a9259a8739..99cd84a17f 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 *
960evas_object_table_add(Evas *evas) 960evas_object_table_add(Evas *evas)
961{ 961{
962 Evas_Object *obj = eo_add(MY_CLASS, evas); 962 Evas_Object *obj = eo_add(MY_CLASS, evas);
963 eo_unref(obj);
964 return obj; 963 return obj;
965} 964}
966 965
diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c
index 37a4c563cf..6a1e1df71f 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)
371 return NULL; 371 return NULL;
372 MAGIC_CHECK_END(); 372 MAGIC_CHECK_END();
373 Evas_Object *eo_obj = eo_add(EVAS_TEXT_CLASS, e); 373 Evas_Object *eo_obj = eo_add(EVAS_TEXT_CLASS, e);
374 eo_unref(eo_obj);
375 return eo_obj; 374 return eo_obj;
376} 375}
377 376
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index e0c286e65f..520761d9ee 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)
5672 return NULL; 5672 return NULL;
5673 MAGIC_CHECK_END(); 5673 MAGIC_CHECK_END();
5674 Evas_Object *eo_obj = eo_add(EVAS_TEXTBLOCK_CLASS, e); 5674 Evas_Object *eo_obj = eo_add(EVAS_TEXTBLOCK_CLASS, e);
5675 eo_unref(eo_obj);
5676 return eo_obj; 5675 return eo_obj;
5677} 5676}
5678 5677
diff --git a/src/lib/evas/canvas/evas_object_textgrid.c b/src/lib/evas/canvas/evas_object_textgrid.c
index 309efa2f69..e2742011bb 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)
1056 return NULL; 1056 return NULL;
1057 MAGIC_CHECK_END(); 1057 MAGIC_CHECK_END();
1058 Evas_Object *eo_obj = eo_add(EVAS_TEXTGRID_CLASS, e); 1058 Evas_Object *eo_obj = eo_add(EVAS_TEXTGRID_CLASS, e);
1059 eo_unref(eo_obj);
1060 return eo_obj; 1059 return eo_obj;
1061} 1060}
1062 1061
diff --git a/src/lib/evas/canvas/evas_out.c b/src/lib/evas/canvas/evas_out.c
index 48a87557d6..27f459e37c 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)
20 return NULL; 20 return NULL;
21 MAGIC_CHECK_END(); 21 MAGIC_CHECK_END();
22 Evas_Object *eo_obj = eo_add(MY_CLASS, e); 22 Evas_Object *eo_obj = eo_add(MY_CLASS, e);
23 eo_unref(eo_obj);
24 return eo_obj; 23 return eo_obj;
25} 24}
26 25
diff --git a/src/tests/eo/children/children_simple.c b/src/tests/eo/children/children_simple.c
index cd351d3001..a85767cb43 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 = {
18 NULL 18 NULL
19}; 19};
20 20
21EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_CLASS, NULL) 21EO_DEFINE_CLASS(simple_class_get, &class_desc, EO_BASE_CLASS, NULL)
22 22
diff --git a/src/tests/eo/composite_objects/composite_objects_comp.c b/src/tests/eo/composite_objects/composite_objects_comp.c
index d880c9823e..17cd95cff2 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)
32 fail_if(!eo_composite_is(simple)); 32 fail_if(!eo_composite_is(simple));
33 33
34 eo_do(obj, eo_key_data_set("simple-obj", simple, NULL)); 34 eo_do(obj, eo_key_data_set("simple-obj", simple, NULL));
35
36 eo_unref(simple);
37} 35}
38 36
39static Eo_Op_Description op_descs[] = { 37static 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 114d2443a4..77fca9cc61 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)
435 435
436 /* Check hierarchy */ 436 /* Check hierarchy */
437 obj = eo_add(SIMPLE_CLASS, NULL); 437 obj = eo_add(SIMPLE_CLASS, NULL);
438 obj2 = eo_add(SIMPLE_CLASS, obj); 438 obj2 = eo_ref(eo_add(SIMPLE_CLASS, obj));
439 439
440 Eo *wref = NULL; 440 Eo *wref = NULL;
441 eo_do(obj2, eo_wref_add(&wref)); 441 eo_do(obj2, eo_wref_add(&wref));
@@ -449,6 +449,16 @@ START_TEST(eo_refs)
449 449
450 fail_if(wref); 450 fail_if(wref);
451 451
452 /* eo_add_ref and normal eo_add */
453 obj = eo_add(SIMPLE_CLASS, NULL);
454 obj2 = eo_add(SIMPLE_CLASS, obj);
455 obj3 = eo_add_ref(SIMPLE_CLASS, obj);
456
457 ck_assert_int_eq(eo_ref_get(obj), 1);
458 ck_assert_int_eq(eo_ref_get(obj2), 1);
459 ck_assert_int_eq(eo_ref_get(obj3), 2);
460
461
452 /* Just check it doesn't seg atm. */ 462 /* Just check it doesn't seg atm. */
453 obj = eo_add(SIMPLE_CLASS, NULL); 463 obj = eo_add(SIMPLE_CLASS, NULL);
454 eo_ref(obj); 464 eo_ref(obj);