eio: fix coding style of Eio_Model.

This commit is contained in:
Cedric BAIL 2015-04-05 15:19:53 +02:00
parent 92be4f9c89
commit 23cfd2b4f4
1 changed files with 117 additions and 110 deletions

View File

@ -184,12 +184,14 @@ _emodel_evt_deleted_ecore_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void
{ {
Eina_List* cur = priv->children_list; Eina_List* cur = priv->children_list;
int i; int i;
for (i = 0; cur; ++i, cur = cur->next) for (i = 0; cur; ++i, cur = cur->next)
{ {
Eio_Model_Data *cur_priv = eo_data_scope_get(cur->data, MY_CLASS); Eio_Model_Data *cur_priv = eo_data_scope_get(cur->data, MY_CLASS);
if(strcmp(cur_priv->path, evt->filename) == 0) if(strcmp(cur_priv->path, evt->filename) == 0)
break; break;
} }
if (cur) if (cur)
{ {
Emodel_Children_Event cevt; Emodel_Children_Event cevt;
@ -269,7 +271,9 @@ _eio_model_emodel_properties_list_get(Eo *obj EINA_UNUSED,
if (priv->properties_array == NULL) if (priv->properties_array == NULL)
{ {
Eina_Value_Struct_Desc *desc = EIO_MODEL_PROPERTIES_DESC; Eina_Value_Struct_Desc *desc = EIO_MODEL_PROPERTIES_DESC;
priv->properties_array = eina_array_new(desc->member_count); priv->properties_array = eina_array_new(desc->member_count);
for (i = 0; i < desc->member_count; ++i) for (i = 0; i < desc->member_count; ++i)
eina_array_push(priv->properties_array, desc->members[i].name); eina_array_push(priv->properties_array, desc->members[i].name);
} }
@ -375,9 +379,11 @@ _eio_model_emodel_monitor_add(Eio_Model_Data *priv)
{ {
priv->monitor = eio_monitor_add(priv->path); priv->monitor = eio_monitor_add(priv->path);
int i = 0; int i = 0;
for (i = 0; priv->mon.mon_event_child_add[i] != EIO_MONITOR_ERROR ; ++i) for (i = 0; priv->mon.mon_event_child_add[i] != EIO_MONITOR_ERROR ; ++i)
priv->mon.ecore_child_add_handler[i] = priv->mon.ecore_child_add_handler[i] =
ecore_event_handler_add(priv->mon.mon_event_child_add[i], _emodel_evt_added_ecore_cb, priv); ecore_event_handler_add(priv->mon.mon_event_child_add[i], _emodel_evt_added_ecore_cb, priv);
for (i = 0; priv->mon.mon_event_child_del[i] != EIO_MONITOR_ERROR ; ++i) for (i = 0; priv->mon.mon_event_child_del[i] != EIO_MONITOR_ERROR ; ++i)
priv->mon.ecore_child_add_handler[i] = priv->mon.ecore_child_add_handler[i] =
ecore_event_handler_add(priv->mon.mon_event_child_del[i], _emodel_evt_deleted_ecore_cb, priv); ecore_event_handler_add(priv->mon.mon_event_child_del[i], _emodel_evt_deleted_ecore_cb, priv);
@ -555,8 +561,10 @@ _eio_model_emodel_child_del(Eo *obj EINA_UNUSED, Eio_Model_Data *priv, Eo *child
child_priv = eo_data_scope_get(child, MY_CLASS); child_priv = eo_data_scope_get(child, MY_CLASS);
EINA_SAFETY_ON_NULL_RETURN_VAL(child_priv, EMODEL_LOAD_STATUS_ERROR); EINA_SAFETY_ON_NULL_RETURN_VAL(child_priv, EMODEL_LOAD_STATUS_ERROR);
eio_file_direct_stat(child_priv->path, &_eio_model_emodel_child_del_stat eio_file_direct_stat(child_priv->path,
, &_eio_error_unlink_cb, child); &_eio_model_emodel_child_del_stat,
&_eio_error_unlink_cb,
child);
eo_ref(child); eo_ref(child);
return priv->load.status; return priv->load.status;
} }
@ -600,13 +608,11 @@ _eio_model_emodel_children_slice_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv,
ln = eina_list_nth_list(priv->children_list, (start-1)); ln = eina_list_nth_list(priv->children_list, (start-1));
if (!ln) if (!ln)
{ {
/**
* In error, we make it more verbose
* by forcing warning to be displayed on terminal.
*/
*children_accessor = NULL; *children_accessor = NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(NULL, priv->load.status); ERR("children not found !");
return priv->load.status;
} }
EINA_LIST_FOREACH(ln, l, child) EINA_LIST_FOREACH(ln, l, child)
{ {
eo_ref(child); eo_ref(child);
@ -614,6 +620,7 @@ _eio_model_emodel_children_slice_get(Eo *obj EINA_UNUSED, Eio_Model_Data *priv,
if (eina_list_count(lr) == count) if (eina_list_count(lr) == count)
break; break;
} }
// This may leak the children Eina_List.
*children_accessor = eina_list_accessor_new(lr); *children_accessor = eina_list_accessor_new(lr);
} }