summaryrefslogtreecommitdiff
path: root/src/examples
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/examples
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/examples')
-rw-r--r--src/examples/ecore/ecore_audio_playback.c2
-rw-r--r--src/examples/ecore/ecore_audio_to_ogg.c14
-rw-r--r--src/examples/elementary/performance/graphical.c4
3 files changed, 10 insertions, 10 deletions
diff --git a/src/examples/ecore/ecore_audio_playback.c b/src/examples/ecore/ecore_audio_playback.c
index 1453dc2..29be761 100644
--- a/src/examples/ecore/ecore_audio_playback.c
+++ b/src/examples/ecore/ecore_audio_playback.c
@@ -201,7 +201,7 @@ static Eina_Bool _play_finished(void *data EINA_UNUSED, const Eo_Event *event)
201 201
202 inputs = eina_list_remove(inputs, event->object); 202 inputs = eina_list_remove(inputs, event->object);
203 ret = ecore_audio_obj_out_input_detach(out, event->object); 203 ret = ecore_audio_obj_out_input_detach(out, event->object);
204 eo_unref(event->object); 204 eo_del(event->object);
205 205
206 if (!ret) 206 if (!ret)
207 printf("Could not detach input %s\n", name); 207 printf("Could not detach input %s\n", name);
diff --git a/src/examples/ecore/ecore_audio_to_ogg.c b/src/examples/ecore/ecore_audio_to_ogg.c
index 7041451..a9451ea 100644
--- a/src/examples/ecore/ecore_audio_to_ogg.c
+++ b/src/examples/ecore/ecore_audio_to_ogg.c
@@ -24,8 +24,8 @@ static Eina_Bool _play_finished(void *data EINA_UNUSED, const Eo_Event *event)
24 printf("Done: %s\n", name); 24 printf("Done: %s\n", name);
25 25
26 ecore_audio_obj_in_output_get(event->object, &out); 26 ecore_audio_obj_in_output_get(event->object, &out);
27 eo_unref(event->object); 27 eo_del(event->object);
28 eo_unref(out); 28 eo_del(out);
29 29
30 ecore_main_loop_quit(); 30 ecore_main_loop_quit();
31 31
@@ -54,7 +54,7 @@ main(int argc, char *argv[])
54 ret = ecore_audio_obj_source_set(in, argv[1]); 54 ret = ecore_audio_obj_source_set(in, argv[1]);
55 if (!ret) { 55 if (!ret) {
56 printf("Could not set %s as input\n", argv[1]); 56 printf("Could not set %s as input\n", argv[1]);
57 eo_unref(in); 57 eo_del(in);
58 return 1; 58 return 1;
59 } 59 }
60 60
@@ -64,16 +64,16 @@ main(int argc, char *argv[])
64 ret = ecore_audio_obj_source_set(out, argv[2]); 64 ret = ecore_audio_obj_source_set(out, argv[2]);
65 if (!ret) { 65 if (!ret) {
66 printf("Could not set %s as output\n", argv[2]); 66 printf("Could not set %s as output\n", argv[2]);
67 eo_unref(in); 67 eo_del(in);
68 eo_unref(out); 68 eo_del(out);
69 return 1; 69 return 1;
70 } 70 }
71 71
72 ret = ecore_audio_obj_out_input_attach(out, in); 72 ret = ecore_audio_obj_out_input_attach(out, in);
73 if (!ret) { 73 if (!ret) {
74 printf("Could not attach input\n"); 74 printf("Could not attach input\n");
75 eo_unref(out); 75 eo_del(out);
76 eo_unref(in); 76 eo_del(in);
77 return 1; 77 return 1;
78 } 78 }
79 79
diff --git a/src/examples/elementary/performance/graphical.c b/src/examples/elementary/performance/graphical.c
index b364022..239655e 100644
--- a/src/examples/elementary/performance/graphical.c
+++ b/src/examples/elementary/performance/graphical.c
@@ -289,7 +289,7 @@ _change_scene_setup()
289 { 289 {
290 evas_canvas3d_node_member_del(globalGraphical.root_node, node); 290 evas_canvas3d_node_member_del(globalGraphical.root_node, node);
291 globalGraphical.list_nodes = eina_list_remove(globalGraphical.list_nodes, node); 291 globalGraphical.list_nodes = eina_list_remove(globalGraphical.list_nodes, node);
292 /*eo_unref(node);Unless evas_canvas3d_destructors work properly*/ 292 /*eo_del(node);Unless evas_canvas3d_destructors work properly*/
293 } 293 }
294 eina_list_free(globalGraphical.list_nodes); 294 eina_list_free(globalGraphical.list_nodes);
295 eina_list_free(l); 295 eina_list_free(l);
@@ -298,7 +298,7 @@ _change_scene_setup()
298 EINA_LIST_FOREACH (globalGraphical.list_meshes, l, m) 298 EINA_LIST_FOREACH (globalGraphical.list_meshes, l, m)
299 { 299 {
300 globalGraphical.list_meshes = eina_list_remove(globalGraphical.list_meshes, m); 300 globalGraphical.list_meshes = eina_list_remove(globalGraphical.list_meshes, m);
301 /*eo_unref(m); Unless evas_canvas3d_destructors work properly*/ 301 /*eo_del(m); Unless evas_canvas3d_destructors work properly*/
302 } 302 }
303 eina_list_free(globalGraphical.list_meshes); 303 eina_list_free(globalGraphical.list_meshes);
304 eina_list_free(l); 304 eina_list_free(l);