summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2016-06-01 13:14:30 +0100
committerTom Hacohen <tom@stosb.com>2016-06-01 13:33:21 +0100
commita6a23389625a5c65747bc648424db18173f563b9 (patch)
treef0c13bdb49c9211a90b9d2a034c2a4333b38af3e /src/tests
parent466d9fbaf1319db4df9d576bdbe196f2557f6627 (diff)
Revert "Eo: Remove eo_del() and make eo_unref() the replacement."
This reverts commit 546ff7bbba788ec834c5608361c0834853f2d5d7. It seems that eo_del() is useful and removing it was creating bugs. The issue is that the way we defined parents in eo, both the parent and the programmer share a reference to the object. When we eo_unref() that reference as the programmer, eo has no way to know it's this specific reference we are freeing, and not a general one, so in some circumstances, for example: eo_ref(child); eo_unref(child); // trying to delete here eo_unref(container); // container is deleted here eo_unref(child); // child already has 0 refs before this point. We would have an issue with references and objects being freed too soon and in general, issue with the references. Having eo_del() solves that, because this one explicitly unparents if there is a parent, meaning the reference ownership is explicitly taken by the programmer. eo_del() is essentially a convenience function around "check if has parent, and if so unparent, otherwise, unref". Which should be used when you want to delete an object although it has a parent, and is equivalent to eo_unref() when it doesn't have one.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/ecore/ecore_test_ecore_audio.c28
-rw-r--r--src/tests/edje/edje_test_edje.c2
-rw-r--r--src/tests/elementary/elm_test_atspi.c2
-rw-r--r--src/tests/emotion/emotion_test_main-eo.c2
-rw-r--r--src/tests/eo/children/children_main.c6
-rw-r--r--src/tests/eo/suite/eo_test_class_behaviour_errors.c4
-rw-r--r--src/tests/eo/suite/eo_test_general.c21
-rw-r--r--src/tests/evas/evas_test_image.c6
-rw-r--r--src/tests/evas/evas_test_mesh.c4
9 files changed, 38 insertions, 37 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_audio.c b/src/tests/ecore/ecore_test_ecore_audio.c
index 2174f9a24c..480e5a2b8b 100644
--- a/src/tests/ecore/ecore_test_ecore_audio.c
+++ b/src/tests/ecore/ecore_test_ecore_audio.c
@@ -83,8 +83,8 @@ START_TEST(ecore_test_ecore_audio_obj_pulse)
83 ecore_main_loop_begin(); 83 ecore_main_loop_begin();
84 fail_if(pulse_context_failed); 84 fail_if(pulse_context_failed);
85 85
86 eo_unref(out); 86 eo_del(out);
87 eo_unref(in); 87 eo_del(in);
88} 88}
89END_TEST 89END_TEST
90#endif 90#endif
@@ -100,7 +100,7 @@ static Eina_Bool
100_idle_del(void *data) 100_idle_del(void *data)
101{ 101{
102 Eo *in = data; 102 Eo *in = data;
103 eo_unref(in); 103 eo_del(in);
104 ecore_idler_add(_quit, NULL); 104 ecore_idler_add(_quit, NULL);
105 105
106 return EINA_FALSE; 106 return EINA_FALSE;
@@ -218,8 +218,8 @@ START_TEST(ecore_test_ecore_audio_obj_tone)
218 218
219 ecore_main_loop_begin(); 219 ecore_main_loop_begin();
220 220
221 eo_unref(in); 221 eo_del(in);
222 eo_unref(out); 222 eo_del(out);
223 223
224 //TODO: Compare and fail 224 //TODO: Compare and fail
225 ecore_file_remove(TESTS_BUILD_DIR"/tmp.wav"); 225 ecore_file_remove(TESTS_BUILD_DIR"/tmp.wav");
@@ -308,8 +308,8 @@ START_TEST(ecore_test_ecore_audio_obj_sndfile)
308 308
309 ecore_main_loop_begin(); 309 ecore_main_loop_begin();
310 310
311 eo_unref(in); 311 eo_del(in);
312 eo_unref(out); 312 eo_del(out);
313 313
314 //TODO: Compare and fail 314 //TODO: Compare and fail
315 ecore_file_remove(TESTS_BUILD_DIR"/tmp.wav"); 315 ecore_file_remove(TESTS_BUILD_DIR"/tmp.wav");
@@ -361,20 +361,20 @@ START_TEST(ecore_test_ecore_audio_obj_in_out)
361 fail_if(eina_list_count(in3) != 2); 361 fail_if(eina_list_count(in3) != 2);
362 fail_if(eina_list_data_get(in3) != in); 362 fail_if(eina_list_data_get(in3) != in);
363 363
364 eo_unref(in2); 364 eo_del(in2);
365 365
366 in3 = ecore_audio_obj_out_inputs_get(out); 366 in3 = ecore_audio_obj_out_inputs_get(out);
367 367
368 fail_if(eina_list_count(in3) != 1); 368 fail_if(eina_list_count(in3) != 1);
369 fail_if(eina_list_data_get(in3) != in); 369 fail_if(eina_list_data_get(in3) != in);
370 370
371 eo_unref(out); 371 eo_del(out);
372 372
373 out2 = ecore_audio_obj_in_output_get(in); 373 out2 = ecore_audio_obj_in_output_get(in);
374 374
375 fail_if(out2); 375 fail_if(out2);
376 376
377 eo_unref(in); 377 eo_del(in);
378} 378}
379END_TEST 379END_TEST
380 380
@@ -433,8 +433,8 @@ START_TEST(ecore_test_ecore_audio_obj_vio)
433 433
434 ecore_main_loop_begin(); 434 ecore_main_loop_begin();
435 435
436 eo_unref(out); 436 eo_del(out);
437 eo_unref(in); 437 eo_del(in);
438} 438}
439END_TEST 439END_TEST
440 440
@@ -533,7 +533,7 @@ START_TEST(ecore_test_ecore_audio_obj_in)
533 fail_if(buf[i] != 0x00); 533 fail_if(buf[i] != 0x00);
534 } 534 }
535 535
536 eo_unref(in); 536 eo_del(in);
537} 537}
538END_TEST 538END_TEST
539 539
@@ -581,7 +581,7 @@ START_TEST(ecore_test_ecore_audio_obj)
581 volume = ecore_audio_obj_volume_get(obj); 581 volume = ecore_audio_obj_volume_get(obj);
582 fail_if(volume != 0.5); 582 fail_if(volume != 0.5);
583 583
584 eo_unref(obj); 584 eo_del(obj);
585 } 585 }
586 586
587} 587}
diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c
index 2b2b47a594..2de5f147b7 100644
--- a/src/tests/edje/edje_test_edje.c
+++ b/src/tests/edje/edje_test_edje.c
@@ -705,7 +705,7 @@ START_TEST(edje_test_table_eoapi)
705 fail_if(!efl_pack_clear(proxy)); 705 fail_if(!efl_pack_clear(proxy));
706 fail_if(efl_content_count(efl_part(obj, "table2")) != 1); 706 fail_if(efl_content_count(efl_part(obj, "table2")) != 1);
707 fail_if(efl_content_count(proxy) != 4); 707 fail_if(efl_content_count(proxy) != 4);
708 eo_unref(proxy); 708 eo_del(proxy);
709 709
710 EDJE_TEST_FREE_EVAS(); 710 EDJE_TEST_FREE_EVAS();
711} 711}
diff --git a/src/tests/elementary/elm_test_atspi.c b/src/tests/elementary/elm_test_atspi.c
index 2b39efc554..82c1564e37 100644
--- a/src/tests/elementary/elm_test_atspi.c
+++ b/src/tests/elementary/elm_test_atspi.c
@@ -438,7 +438,7 @@ START_TEST (elm_atspi_relationship_remove)
438 /* Test if relationship is implicity removed when object is deleted */ 438 /* Test if relationship is implicity removed when object is deleted */
439 elm_interface_atspi_accessible_relationship_append(g_btn, ELM_ATSPI_RELATION_FLOWS_TO, g_bg); 439 elm_interface_atspi_accessible_relationship_append(g_btn, ELM_ATSPI_RELATION_FLOWS_TO, g_bg);
440 elm_interface_atspi_accessible_relationship_append(g_btn, ELM_ATSPI_RELATION_FLOWS_FROM, g_bg); 440 elm_interface_atspi_accessible_relationship_append(g_btn, ELM_ATSPI_RELATION_FLOWS_FROM, g_bg);
441 eo_unref(g_bg); 441 eo_del(g_bg);
442 set = elm_interface_atspi_accessible_relation_set_get(g_btn); 442 set = elm_interface_atspi_accessible_relation_set_get(g_btn);
443 443
444 rel_to = rel_from = NULL; 444 rel_to = rel_from = NULL;
diff --git a/src/tests/emotion/emotion_test_main-eo.c b/src/tests/emotion/emotion_test_main-eo.c
index 83937428c3..86a0cbb93e 100644
--- a/src/tests/emotion/emotion_test_main-eo.c
+++ b/src/tests/emotion/emotion_test_main-eo.c
@@ -97,7 +97,7 @@ main_signal_exit(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev EINA_
97 EINA_LIST_FREE(video_objs, o) 97 EINA_LIST_FREE(video_objs, o)
98 { 98 {
99 emotion_object_last_position_save(o); 99 emotion_object_last_position_save(o);
100 eo_unref(o); 100 eo_del(o);
101 } 101 }
102 return EINA_TRUE; 102 return EINA_TRUE;
103} 103}
diff --git a/src/tests/eo/children/children_main.c b/src/tests/eo/children/children_main.c
index ba6f6a285e..9d30277333 100644
--- a/src/tests/eo/children/children_main.c
+++ b/src/tests/eo/children/children_main.c
@@ -40,7 +40,7 @@ main(int argc, char *argv[])
40 40
41 eina_iterator_free(iter); 41 eina_iterator_free(iter);
42 42
43 eo_unref(child2); 43 eo_del(child2);
44 44
45 iter = eo_children_iterator_new(parent); 45 iter = eo_children_iterator_new(parent);
46 fail_if(!iter); 46 fail_if(!iter);
@@ -52,7 +52,7 @@ main(int argc, char *argv[])
52 eina_iterator_free(iter); 52 eina_iterator_free(iter);
53 53
54 54
55 eo_unref(child1); 55 eo_del(child1);
56 56
57 iter = eo_children_iterator_new(parent); 57 iter = eo_children_iterator_new(parent);
58 fail_if(!iter); 58 fail_if(!iter);
@@ -62,7 +62,7 @@ main(int argc, char *argv[])
62 eina_iterator_free(iter); 62 eina_iterator_free(iter);
63 63
64 64
65 eo_unref(child3); 65 eo_del(child3);
66 66
67 iter = eo_children_iterator_new(parent); 67 iter = eo_children_iterator_new(parent);
68 fail_if(iter); 68 fail_if(iter);
diff --git a/src/tests/eo/suite/eo_test_class_behaviour_errors.c b/src/tests/eo/suite/eo_test_class_behaviour_errors.c
index 8533b3105e..12c478f454 100644
--- a/src/tests/eo/suite/eo_test_class_behaviour_errors.c
+++ b/src/tests/eo/suite/eo_test_class_behaviour_errors.c
@@ -81,8 +81,8 @@ START_TEST(eo_destructor_double_del)
81 fail_if(!obj); 81 fail_if(!obj);
82 82
83 TEST_EO_ERROR("_eo_unref", "Object %p already destructed."); 83 TEST_EO_ERROR("_eo_unref", "Object %p already destructed.");
84 eo_unref(obj); 84 eo_del(obj);
85 eo_unref(obj); 85 eo_del(obj);
86 86
87 eina_log_print_cb_set(eina_log_print_cb_stderr, NULL); 87 eina_log_print_cb_set(eina_log_print_cb_stderr, NULL);
88 88
diff --git a/src/tests/eo/suite/eo_test_general.c b/src/tests/eo/suite/eo_test_general.c
index 055bd3c12a..ddbe0987cc 100644
--- a/src/tests/eo/suite/eo_test_general.c
+++ b/src/tests/eo/suite/eo_test_general.c
@@ -378,11 +378,11 @@ START_TEST(eo_composite_tests)
378 fail_if(!eo_composite_part_is(obj2)); 378 fail_if(!eo_composite_part_is(obj2));
379 379
380 /* Check that a deletion of a child detaches from the parent. */ 380 /* Check that a deletion of a child detaches from the parent. */
381 eo_unref(obj2); 381 eo_del(obj2);
382 fail_if(!eo_composite_attach(obj3, obj)); 382 fail_if(!eo_composite_attach(obj3, obj));
383 383
384 /* Check that a deletion of the parent detaches the child. */ 384 /* Check that a deletion of the parent detaches the child. */
385 eo_unref(obj3); 385 eo_del(obj3);
386 fail_if(eo_composite_part_is(obj)); 386 fail_if(eo_composite_part_is(obj));
387 387
388 eo_unref(obj); 388 eo_unref(obj);
@@ -582,9 +582,9 @@ START_TEST(eo_refs)
582 ck_assert_int_eq(eo_ref_get(obj2), 1); 582 ck_assert_int_eq(eo_ref_get(obj2), 1);
583 ck_assert_int_eq(eo_ref_get(obj3), 1); 583 ck_assert_int_eq(eo_ref_get(obj3), 1);
584 584
585 eo_unref(obj); 585 eo_del(obj);
586 eo_unref(obj2); 586 eo_del(obj2);
587 eo_unref(obj3); 587 eo_del(obj3);
588 588
589 /* Just check it doesn't seg atm. */ 589 /* Just check it doesn't seg atm. */
590 obj = eo_add(SIMPLE_CLASS, NULL); 590 obj = eo_add(SIMPLE_CLASS, NULL);
@@ -596,7 +596,7 @@ START_TEST(eo_refs)
596 obj2 = eo_add(SIMPLE_CLASS, obj); 596 obj2 = eo_add(SIMPLE_CLASS, obj);
597 eo_unref(obj2); 597 eo_unref(obj2);
598 eo_ref(obj2); 598 eo_ref(obj2);
599 eo_unref(obj2); 599 eo_del(obj2);
600 eo_unref(obj); 600 eo_unref(obj);
601 601
602 eo_shutdown(); 602 eo_shutdown();
@@ -811,6 +811,7 @@ START_TEST(eo_magic_checks)
811 811
812 eo_ref((Eo *) buf); 812 eo_ref((Eo *) buf);
813 eo_unref((Eo *) buf); 813 eo_unref((Eo *) buf);
814 eo_del((Eo *) buf);
814 815
815 eo_isa((Eo *) buf, SIMPLE_CLASS); 816 eo_isa((Eo *) buf, SIMPLE_CLASS);
816 eo_isa(obj, (Eo_Class *) buf); 817 eo_isa(obj, (Eo_Class *) buf);
@@ -1125,7 +1126,7 @@ START_TEST(eo_del_intercept)
1125 fail_if(!obj); 1126 fail_if(!obj);
1126 fail_if(!eo_isa(obj, klass)); 1127 fail_if(!eo_isa(obj, klass));
1127 eo_del_intercept_set(obj, _del_intercept); 1128 eo_del_intercept_set(obj, _del_intercept);
1128 eo_unref(obj); 1129 eo_del(obj);
1129 fail_if(!intercepted); 1130 fail_if(!intercepted);
1130 fail_if(eo_isa(obj, klass)); 1131 fail_if(eo_isa(obj, klass));
1131 1132
@@ -1185,7 +1186,7 @@ START_TEST(eo_name)
1185 objtmp = eo_name_find(obj, "*mple:joe"); 1186 objtmp = eo_name_find(obj, "*mple:joe");
1186 fail_if(objtmp != obj2); 1187 fail_if(objtmp != obj2);
1187 1188
1188 eo_unref(obj); 1189 eo_del(obj);
1189 1190
1190 eo_shutdown(); 1191 eo_shutdown();
1191} 1192}
@@ -1215,7 +1216,7 @@ START_TEST(eo_comment)
1215 comment = eo_comment_get(obj); 1216 comment = eo_comment_get(obj);
1216 fail_if(NULL != comment); 1217 fail_if(NULL != comment);
1217 1218
1218 eo_unref(obj); 1219 eo_del(obj);
1219 1220
1220 eo_shutdown(); 1221 eo_shutdown();
1221} 1222}
@@ -1232,7 +1233,7 @@ START_TEST(eo_rec_interface)
1232 objtmp = eo_provider_find(obj2, SEARCHABLE_CLASS); 1233 objtmp = eo_provider_find(obj2, SEARCHABLE_CLASS);
1233 fail_if(objtmp != s); 1234 fail_if(objtmp != s);
1234 1235
1235 eo_unref(obj); 1236 eo_del(obj);
1236 1237
1237 eo_shutdown(); 1238 eo_shutdown();
1238} 1239}
diff --git a/src/tests/evas/evas_test_image.c b/src/tests/evas/evas_test_image.c
index 1408525dc4..7f90754872 100644
--- a/src/tests/evas/evas_test_image.c
+++ b/src/tests/evas/evas_test_image.c
@@ -638,16 +638,16 @@ START_TEST(evas_object_image_defaults)
638 fail_if(evas_object_image_filled_get(o)); 638 fail_if(evas_object_image_filled_get(o));
639 evas_object_image_fill_get(o, &x, &y, &w, &h); 639 evas_object_image_fill_get(o, &x, &y, &w, &h);
640 fail_if(x || y || w || h); 640 fail_if(x || y || w || h);
641 eo_unref(o); 641 eo_del(o);
642 642
643 o = evas_object_image_filled_add(e); 643 o = evas_object_image_filled_add(e);
644 fail_if(!evas_object_image_filled_get(o)); 644 fail_if(!evas_object_image_filled_get(o));
645 eo_unref(o); 645 eo_del(o);
646 646
647 /* test eo defaults */ 647 /* test eo defaults */
648 o = eo_add(EVAS_IMAGE_CLASS, e); 648 o = eo_add(EVAS_IMAGE_CLASS, e);
649 fail_if(!efl_gfx_fill_auto_get(o)); 649 fail_if(!efl_gfx_fill_auto_get(o));
650 eo_unref(o); 650 eo_del(o);
651 651
652 evas_free(e); 652 evas_free(e);
653 evas_shutdown(); 653 evas_shutdown();
diff --git a/src/tests/evas/evas_test_mesh.c b/src/tests/evas/evas_test_mesh.c
index 9dea211c04..aba8a0bfc8 100644
--- a/src/tests/evas/evas_test_mesh.c
+++ b/src/tests/evas/evas_test_mesh.c
@@ -65,8 +65,8 @@
65 fail_if(!set_ok); \ 65 fail_if(!set_ok); \
66 res = _compare_meshes(mesh, mesh2); \ 66 res = _compare_meshes(mesh, mesh2); \
67 fail_if(res == 1); \ 67 fail_if(res == 1); \
68 eo_unref(mesh2); \ 68 eo_del(mesh2); \
69 eo_unref(mesh); \ 69 eo_del(mesh); \
70 unlink(buffer); \ 70 unlink(buffer); \
71 } 71 }
72 72