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.
This commit is contained in:
parent
712af11641
commit
250be1e27a
|
@ -201,7 +201,7 @@ static Eina_Bool _play_finished(void *data EINA_UNUSED, const Eo_Event *event)
|
|||
|
||||
inputs = eina_list_remove(inputs, event->object);
|
||||
ret = ecore_audio_obj_out_input_detach(out, event->object);
|
||||
eo_unref(event->object);
|
||||
eo_del(event->object);
|
||||
|
||||
if (!ret)
|
||||
printf("Could not detach input %s\n", name);
|
||||
|
|
|
@ -24,8 +24,8 @@ static Eina_Bool _play_finished(void *data EINA_UNUSED, const Eo_Event *event)
|
|||
printf("Done: %s\n", name);
|
||||
|
||||
ecore_audio_obj_in_output_get(event->object, &out);
|
||||
eo_unref(event->object);
|
||||
eo_unref(out);
|
||||
eo_del(event->object);
|
||||
eo_del(out);
|
||||
|
||||
ecore_main_loop_quit();
|
||||
|
||||
|
@ -54,7 +54,7 @@ main(int argc, char *argv[])
|
|||
ret = ecore_audio_obj_source_set(in, argv[1]);
|
||||
if (!ret) {
|
||||
printf("Could not set %s as input\n", argv[1]);
|
||||
eo_unref(in);
|
||||
eo_del(in);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -64,16 +64,16 @@ main(int argc, char *argv[])
|
|||
ret = ecore_audio_obj_source_set(out, argv[2]);
|
||||
if (!ret) {
|
||||
printf("Could not set %s as output\n", argv[2]);
|
||||
eo_unref(in);
|
||||
eo_unref(out);
|
||||
eo_del(in);
|
||||
eo_del(out);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = ecore_audio_obj_out_input_attach(out, in);
|
||||
if (!ret) {
|
||||
printf("Could not attach input\n");
|
||||
eo_unref(out);
|
||||
eo_unref(in);
|
||||
eo_del(out);
|
||||
eo_del(in);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -289,7 +289,7 @@ _change_scene_setup()
|
|||
{
|
||||
evas_canvas3d_node_member_del(globalGraphical.root_node, node);
|
||||
globalGraphical.list_nodes = eina_list_remove(globalGraphical.list_nodes, node);
|
||||
/*eo_unref(node);Unless evas_canvas3d_destructors work properly*/
|
||||
/*eo_del(node);Unless evas_canvas3d_destructors work properly*/
|
||||
}
|
||||
eina_list_free(globalGraphical.list_nodes);
|
||||
eina_list_free(l);
|
||||
|
@ -298,7 +298,7 @@ _change_scene_setup()
|
|||
EINA_LIST_FOREACH (globalGraphical.list_meshes, l, m)
|
||||
{
|
||||
globalGraphical.list_meshes = eina_list_remove(globalGraphical.list_meshes, m);
|
||||
/*eo_unref(m); Unless evas_canvas3d_destructors work properly*/
|
||||
/*eo_del(m); Unless evas_canvas3d_destructors work properly*/
|
||||
}
|
||||
eina_list_free(globalGraphical.list_meshes);
|
||||
eina_list_free(l);
|
||||
|
|
Loading…
Reference in New Issue