summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-08-26 10:32:32 +0100
committerTom Hacohen <tom@stosb.com>2015-08-26 10:33:24 +0100
commit37abea3831f62ac612b377bb48ce6c90e076dd25 (patch)
tree712b3dffab03fd13a111b6c60062f2d25acc1024
parent9c78ee0bf4125c095e85f7fcf9921586cda64a52 (diff)
Revert "Eo base: Change parent_set to be an assignment of ref."
Damn, this breaks some things. Reverting until fixed. This reverts commit 9c78ee0bf4125c095e85f7fcf9921586cda64a52.
-rw-r--r--src/lib/eo/eo.c6
-rw-r--r--src/lib/eo/eo_base_class.c8
-rw-r--r--src/tests/eo/suite/eo_test_general.c23
3 files changed, 5 insertions, 32 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 4cd992dc71..b5e24a91a5 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -917,13 +917,13 @@ _eo_add_internal_start(const char *file, int line, const Eo_Class *klass_id, Eo
917 917
918 eo_do(eo_id, eo_parent_set(parent_id)); 918 eo_do(eo_id, eo_parent_set(parent_id));
919 919
920 /* If there's a parent. Ref. Eo_add should return an object with either a 920 /* If there's a parent. Unref. Eo_add should return an object with either a
921 * parent ref, or with the lack of, just a ref. */ 921 * parent ref, or with the lack of, just a ref. */
922 { 922 {
923 Eo *parent_tmp; 923 Eo *parent_tmp;
924 if (ref && eo_do_ret(eo_id, parent_tmp, eo_parent_get())) 924 if (!ref && eo_do_ret(eo_id, parent_tmp, eo_parent_get()))
925 { 925 {
926 _eo_ref(obj); 926 _eo_unref(obj);
927 } 927 }
928 } 928 }
929 929
diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c
index bbdf426ee7..0c5f3ef01d 100644
--- a/src/lib/eo/eo_base_class.c
+++ b/src/lib/eo/eo_base_class.c
@@ -124,12 +124,7 @@ _eo_base_parent_set(Eo *obj, Eo_Base_Data *pd, Eo *parent_id)
124 ERR("CONTACT DEVS!!! SHOULD NEVER HAPPEN!!! Old parent %p for object %p is not a valid Eo object.", 124 ERR("CONTACT DEVS!!! SHOULD NEVER HAPPEN!!! Old parent %p for object %p is not a valid Eo object.",
125 pd->parent, obj); 125 pd->parent, obj);
126 } 126 }
127 127 eo_unref(obj);
128 /* Only unref if we don't have a new parent instead. */
129 if (!parent_id)
130 {
131 eo_unref(obj);
132 }
133 } 128 }
134 129
135 /* Set new parent */ 130 /* Set new parent */
@@ -143,6 +138,7 @@ _eo_base_parent_set(Eo *obj, Eo_Base_Data *pd, Eo *parent_id)
143 pd->parent = parent_id; 138 pd->parent = parent_id;
144 parent_pd->children = eina_list_append(parent_pd->children, obj); 139 parent_pd->children = eina_list_append(parent_pd->children, obj);
145 pd->parent_list = eina_list_last(parent_pd->children); 140 pd->parent_list = eina_list_last(parent_pd->children);
141 eo_ref(obj);
146 } 142 }
147 else 143 else
148 { 144 {
diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c
index 9121f8fac0..47064cf373 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -464,29 +464,6 @@ START_TEST(eo_refs)
464 ck_assert_int_eq(eo_ref_get(obj2), 1); 464 ck_assert_int_eq(eo_ref_get(obj2), 1);
465 ck_assert_int_eq(eo_ref_get(obj3), 2); 465 ck_assert_int_eq(eo_ref_get(obj3), 2);
466 466
467 /* Setting and removing parents. */
468 obj = eo_add(SIMPLE_CLASS, NULL);
469 obj2 = eo_ref(eo_add(SIMPLE_CLASS, obj));
470 obj3 = eo_ref(eo_add(SIMPLE_CLASS, NULL));
471
472 eo_do(obj2, eo_parent_set(obj3));
473 eo_do(obj3, eo_parent_set(obj));
474 ck_assert_int_eq(eo_ref_get(obj2), 2);
475 ck_assert_int_eq(eo_ref_get(obj3), 2);
476
477 eo_do(obj2, eo_parent_set(NULL));
478 eo_do(obj3, eo_parent_set(NULL));
479 ck_assert_int_eq(eo_ref_get(obj2), 1);
480 ck_assert_int_eq(eo_ref_get(obj3), 1);
481
482 eo_do(obj2, eo_parent_set(obj));
483 eo_do(obj3, eo_parent_set(obj));
484 ck_assert_int_eq(eo_ref_get(obj2), 1);
485 ck_assert_int_eq(eo_ref_get(obj3), 1);
486
487 eo_del(obj);
488 eo_del(obj2);
489 eo_del(obj3);
490 467
491 /* Just check it doesn't seg atm. */ 468 /* Just check it doesn't seg atm. */
492 obj = eo_add(SIMPLE_CLASS, NULL); 469 obj = eo_add(SIMPLE_CLASS, NULL);