summaryrefslogtreecommitdiff
path: root/src/lib/eo/eo.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-05-15 15:35:48 -0700
committerCedric BAIL <cedric@osg.samsung.com>2018-05-24 16:02:20 -0700
commit0cc07f4e6bdd6762fcb3327e7a127356b22eef04 (patch)
treefdeea1c021b86fa2357625a95838676209aaedd0 /src/lib/eo/eo.c
parent2894a2e3c3786e707fa736c64c59d73520fbba82 (diff)
eo: try to make efl_add and efl_add_ref refcounting sane in all case.
Diffstat (limited to 'src/lib/eo/eo.c')
-rw-r--r--src/lib/eo/eo.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 5396a12..f75f376 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -873,7 +873,7 @@ _efl_add_internal_start(const char *file, int line, const Efl_Class *klass_id, E
873 // Check that in the case of efl_add we do pass a parent. 873 // Check that in the case of efl_add we do pass a parent.
874 if (!ref && !parent_id) 874 if (!ref && !parent_id)
875 ERR("Creation of '%s' object at line %i in '%s' is done without parent. This should use efl_add_ref.", 875 ERR("Creation of '%s' object at line %i in '%s' is done without parent. This should use efl_add_ref.",
876 klass->desc->name, line, file); 876 klass->desc->name, line, file);
877 877
878 if (parent_id) 878 if (parent_id)
879 { 879 {
@@ -898,7 +898,7 @@ _efl_add_internal_start(const char *file, int line, const Efl_Class *klass_id, E
898 eina_spinlock_release(&klass->objects.trash_lock); 898 eina_spinlock_release(&klass->objects.trash_lock);
899 899
900 obj->opt = eina_cow_alloc(efl_object_optional_cow); 900 obj->opt = eina_cow_alloc(efl_object_optional_cow);
901 obj->refcount++; 901 _efl_ref(obj);
902 obj->klass = klass; 902 obj->klass = klass;
903 903
904 obj->header.id = _eo_id_allocate(obj, parent_id); 904 obj->header.id = _eo_id_allocate(obj, parent_id);
@@ -927,11 +927,11 @@ ok_nomatch_back:
927ok_nomatch: 927ok_nomatch:
928 { 928 {
929 EO_OBJ_POINTER_GOTO_PROXY(eo_id, new_obj, err_newid); 929 EO_OBJ_POINTER_GOTO_PROXY(eo_id, new_obj, err_newid);
930 /* We have two refs at this point. */ 930 efl_ref(eo_id);
931 /* We might have two refs on the old object at this point. */
932 efl_parent_set((Eo *) obj->header.id, NULL);
933 efl_unref(_eo_obj_id_get(obj));
931 _efl_unref(obj); 934 _efl_unref(obj);
932 if (parent_id) efl_del((Eo *) obj->header.id);
933 else _efl_unref(obj);
934 _efl_ref(new_obj);
935 EO_OBJ_DONE(eo_id); 935 EO_OBJ_DONE(eo_id);
936 } 936 }
937 goto ok_nomatch_back; 937 goto ok_nomatch_back;
@@ -939,10 +939,10 @@ ok_nomatch:
939err_noid: 939err_noid:
940 ERR("in %s:%d: Object of class '%s' - Error while constructing object", 940 ERR("in %s:%d: Object of class '%s' - Error while constructing object",
941 file, line, klass->desc->name); 941 file, line, klass->desc->name);
942 /* We have two refs at this point. */ 942 /* We might have two refs at this point. */
943 efl_parent_set((Eo *) obj->header.id, NULL);
944 efl_unref(_eo_obj_id_get(obj));
943 _efl_unref(obj); 945 _efl_unref(obj);
944 if (parent_id) efl_del((Eo *) obj->header.id);
945 else _efl_unref(obj);
946err_newid: 946err_newid:
947 if (parent_id) EO_OBJ_DONE(parent_id); 947 if (parent_id) EO_OBJ_DONE(parent_id);
948 return NULL; 948 return NULL;
@@ -992,9 +992,9 @@ err_condtor:
992 klass->desc->name); 992 klass->desc->name);
993 } 993 }
994cleanup: 994cleanup:
995 efl_parent_set((Eo *) obj->header.id, NULL);
996 efl_unref((Eo *) obj->header.id);
995 _efl_unref(obj); 997 _efl_unref(obj);
996 if (efl_parent_get(eo_id)) efl_del((Eo *) obj->header.id);
997 else _efl_unref(obj);
998 EO_OBJ_DONE(eo_id); 998 EO_OBJ_DONE(eo_id);
999 return NULL; 999 return NULL;
1000} 1000}
@@ -1006,13 +1006,9 @@ _efl_add_end(Eo *eo_id, Eina_Bool is_ref, Eina_Bool is_fallback)
1006 Eo *ret = efl_finalize(eo_id); 1006 Eo *ret = efl_finalize(eo_id);
1007 ret = _efl_add_internal_end(eo_id, ret); 1007 ret = _efl_add_internal_end(eo_id, ret);
1008 1008
1009 if (ret && is_ref) 1009 if (ret && !is_ref)
1010 { 1010 {
1011 if (efl_parent_get(eo_id)) 1011 efl_unref(ret);
1012 {
1013 efl_ref(eo_id);
1014 }
1015 _efl_object_parent_sink_set(eo_id, EINA_TRUE);
1016 } 1012 }
1017 1013
1018 if (is_fallback) 1014 if (is_fallback)