forked from enlightenment/efl
efl: use eina_streq for all property operation in model to avoid crash on NULL property name.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D9266
This commit is contained in:
parent
4e4210b0f3
commit
fce5645d80
|
@ -197,7 +197,7 @@ _efl_composite_model_efl_ui_view_model_set(Eo *obj EINA_UNUSED, Efl_Composite_Mo
|
|||
properties = efl_model_properties_get(pd->source);
|
||||
EINA_ITERATOR_FOREACH(properties, property)
|
||||
{
|
||||
if (!strcmp(property, EFL_COMPOSITE_MODEL_CHILD_INDEX))
|
||||
if (eina_streq(property, EFL_COMPOSITE_MODEL_CHILD_INDEX))
|
||||
{
|
||||
pd->need_index = EINA_FALSE;
|
||||
break;
|
||||
|
@ -216,7 +216,7 @@ static Eina_Future *
|
|||
_efl_composite_model_efl_model_property_set(Eo *obj, Efl_Composite_Model_Data *pd,
|
||||
const char *property, Eina_Value *value)
|
||||
{
|
||||
if (pd->need_index && !strcmp(property, EFL_COMPOSITE_MODEL_CHILD_INDEX))
|
||||
if (pd->need_index && eina_streq(property, EFL_COMPOSITE_MODEL_CHILD_INDEX))
|
||||
{
|
||||
if (pd->set_index || !pd->source)
|
||||
return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_READ_ONLY);
|
||||
|
@ -233,7 +233,7 @@ _efl_composite_model_efl_model_property_get(const Eo *obj EINA_UNUSED, Efl_Compo
|
|||
const char *property)
|
||||
{
|
||||
Eina_Value *try;
|
||||
if (pd->need_index && !strcmp(property, EFL_COMPOSITE_MODEL_CHILD_INDEX))
|
||||
if (pd->need_index && eina_streq(property, EFL_COMPOSITE_MODEL_CHILD_INDEX))
|
||||
{
|
||||
if (pd->set_index)
|
||||
return eina_value_uint_new(pd->index);
|
||||
|
|
|
@ -551,7 +551,7 @@ static Eina_Value *
|
|||
_efl_filter_model_efl_model_property_get(const Eo *obj, Efl_Filter_Model_Data *pd,
|
||||
const char *property)
|
||||
{
|
||||
if (pd->self && !strcmp(property, EFL_COMPOSITE_MODEL_CHILD_INDEX))
|
||||
if (pd->self && eina_streq(property, EFL_COMPOSITE_MODEL_CHILD_INDEX))
|
||||
{
|
||||
return eina_value_uint64_new(pd->self->mapped);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ _propagate_future(void *data, const Efl_Event *event)
|
|||
Efl_Loop_Model_Watcher_Data *wd = data;
|
||||
|
||||
EINA_ARRAY_ITER_NEXT(ev->changed_properties, i, property, it)
|
||||
if (property == wd->property || !strcmp(property, wd->property))
|
||||
if (property == wd->property || eina_streq(property, wd->property))
|
||||
{
|
||||
Eina_Value *v = efl_model_property_get(wd->obj, wd->property);
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ _efl_select_model_efl_model_property_set(Eo *obj,
|
|||
{
|
||||
Eina_Value vf = EINA_VALUE_EMPTY;
|
||||
|
||||
if (!strcmp("single_selection", property))
|
||||
if (eina_streq("single_selection", property))
|
||||
{
|
||||
Eina_Bool single_selection = pd->single_selection;
|
||||
Eina_Bool changed;
|
||||
|
@ -275,7 +275,7 @@ _efl_select_model_efl_model_property_set(Eo *obj,
|
|||
return efl_loop_future_resolved(obj, vf);
|
||||
}
|
||||
|
||||
if (!strcmp("child.selected", property))
|
||||
if (eina_streq("child.selected", property))
|
||||
{
|
||||
unsigned long l = 0;
|
||||
|
||||
|
@ -288,7 +288,7 @@ _efl_select_model_efl_model_property_set(Eo *obj,
|
|||
.free = _clear_child);
|
||||
}
|
||||
|
||||
if (pd->parent && !strcmp("self.selected", property))
|
||||
if (pd->parent && eina_streq("self.selected", property))
|
||||
{
|
||||
Eina_Bool prevflag = EINA_FALSE, newflag = EINA_FALSE;
|
||||
Eina_Bool single_selection = EINA_FALSE;
|
||||
|
@ -364,10 +364,10 @@ _efl_select_model_efl_model_property_set(Eo *obj,
|
|||
static Eina_Value *
|
||||
_efl_select_model_efl_model_property_get(const Eo *obj, Efl_Select_Model_Data *pd, const char *property)
|
||||
{
|
||||
if (!strcmp("single_selection", property))
|
||||
if (eina_streq("single_selection", property))
|
||||
return eina_value_bool_new(pd->single_selection);
|
||||
// Last selected child
|
||||
if (!strcmp("child.selected", property))
|
||||
if (eina_streq("child.selected", property))
|
||||
{
|
||||
if (pd->none)
|
||||
return eina_value_error_new(EFL_MODEL_ERROR_INCORRECT_VALUE);
|
||||
|
@ -375,7 +375,7 @@ _efl_select_model_efl_model_property_get(const Eo *obj, Efl_Select_Model_Data *p
|
|||
return eina_value_ulong_new(pd->last);
|
||||
}
|
||||
// Redirect to are we ourself selected
|
||||
if (pd->parent && !strcmp("self.selected", property))
|
||||
if (pd->parent && eina_streq("self.selected", property))
|
||||
{
|
||||
return efl_model_property_get(efl_super(obj, EFL_SELECT_MODEL_CLASS), "selected");
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ _already_added(Efl_Io_Model_Data *pd, const char *path)
|
|||
|
||||
EINA_LIST_FOREACH(pd->files, node, mi)
|
||||
{
|
||||
if (!strcmp(mi->path, path))
|
||||
if (eina_streq(mi->path, path))
|
||||
return EINA_TRUE;
|
||||
}
|
||||
return EINA_FALSE;
|
||||
|
@ -99,7 +99,7 @@ _efl_model_evt_added_ecore_cb(void *data, int type, void *event)
|
|||
obj = pd->self;
|
||||
|
||||
path = ecore_file_dir_get(ev->filename);
|
||||
if (strcmp(pd->path, path) != 0)
|
||||
if (!eina_streq(pd->path, path))
|
||||
goto end;
|
||||
|
||||
spath = eina_stringshare_add(ev->filename);
|
||||
|
@ -698,7 +698,7 @@ _efl_io_model_efl_model_property_get(const Eo *obj, Efl_Io_Model_Data *pd, const
|
|||
|
||||
for (i = 0; i < EINA_C_ARRAY_LENGTH(properties); ++i)
|
||||
if (property == properties[i].name ||
|
||||
!strcmp(property, properties[i].name))
|
||||
eina_streq(property, properties[i].name))
|
||||
return properties[i].cb(obj, pd);
|
||||
|
||||
return efl_model_property_get(efl_super(obj, EFL_IO_MODEL_CLASS), property);
|
||||
|
@ -718,7 +718,7 @@ _efl_io_model_efl_model_property_set(Eo *obj,
|
|||
if (!property) goto on_error;
|
||||
|
||||
err = EFL_MODEL_ERROR_NOT_SUPPORTED;
|
||||
if (strcmp(property, "path") != 0) goto on_error;
|
||||
if (!eina_streq(property, "path")) goto on_error;
|
||||
|
||||
if (finalized && pd->request.move) goto on_error;
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ _eldbus_model_efl_model_property_set(Eo *obj,
|
|||
{
|
||||
Eina_Error err = EFL_MODEL_ERROR_READ_ONLY;
|
||||
|
||||
if (strcmp(property, UNIQUE_NAME_PROPERTY))
|
||||
if (!eina_streq(property, UNIQUE_NAME_PROPERTY))
|
||||
err = EFL_MODEL_ERROR_NOT_FOUND;
|
||||
return efl_loop_future_rejected(obj, err);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ _eldbus_model_efl_model_property_get(const Eo *obj,
|
|||
{
|
||||
DBG("(%p): property=%s", obj, property);
|
||||
|
||||
if (strcmp(property, UNIQUE_NAME_PROPERTY) != 0) goto on_error;
|
||||
if (!eina_streq(property, UNIQUE_NAME_PROPERTY)) goto on_error;
|
||||
|
||||
if (!pd->connection) eldbus_model_connect_do(pd);
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ _eldbus_model_object_concatenate_path(const char *root_path,
|
|||
const char *relative_path)
|
||||
{
|
||||
Eina_Strbuf *buffer;
|
||||
const char *format = (strcmp(root_path, "/") != 0) ? "%s/%s" : "%s%s";
|
||||
const char *format = (!eina_streq(root_path, "/")) ? "%s/%s" : "%s%s";
|
||||
char *absolute_path = NULL;
|
||||
|
||||
buffer = eina_strbuf_new();
|
||||
|
|
|
@ -115,14 +115,14 @@ _efl_ui_average_model_efl_model_property_set(Eo *obj, Efl_Ui_Average_Model_Data
|
|||
if (!pd->parent) goto end;
|
||||
|
||||
// In vertical list mode we do not need to compute the average width size
|
||||
/* if (!strcmp(property, _efl_model_property_selfw)) */
|
||||
/* if (eina_streq(property, _efl_model_property_selfw)) */
|
||||
/* { */
|
||||
/* f = _efl_ui_average_model_prepare(obj, &pd->parent->total.width, */
|
||||
/* pd->wseen ? NULL : &pd->parent->total.wseen, */
|
||||
/* property, value, EINA_TRUE); */
|
||||
/* pd->wseen = EINA_TRUE; */
|
||||
/* } */
|
||||
if (!strcmp(property, _efl_model_property_selfh))
|
||||
if (eina_streq(property, _efl_model_property_selfh))
|
||||
{
|
||||
f = _efl_ui_average_model_prepare(obj, &pd->parent->total.height,
|
||||
pd->hseen ? NULL : &pd->parent->total.hseen,
|
||||
|
@ -167,10 +167,10 @@ _efl_ui_average_model_efl_model_property_get(const Eo *obj, Efl_Ui_Average_Model
|
|||
t = eina_value_type_get(r);
|
||||
if (t == EINA_VALUE_TYPE_UINT)
|
||||
{
|
||||
if (!strcmp(property, _efl_model_property_totalh))
|
||||
if (eina_streq(property, _efl_model_property_totalh))
|
||||
r = _efl_ui_average_model_compute(obj, r, pd->total.height, pd->total.hseen);
|
||||
// We do not need to average the width in vertical list mode as this is done by the parent class
|
||||
/* if (!strcmp(property, _efl_model_property_totalw)) */
|
||||
/* if (eina_streq(property, _efl_model_property_totalw)) */
|
||||
/* r = _efl_ui_average_model_compute(obj, r, pd->total.width, pd->total.wseen); */
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ _efl_ui_exact_model_efl_model_property_set(Eo *obj, Efl_Ui_Exact_Model_Data *pd,
|
|||
{
|
||||
if (pd->parent)
|
||||
{
|
||||
if (!strcmp(property, _efl_model_property_selfw))
|
||||
if (eina_streq(property, _efl_model_property_selfw))
|
||||
{
|
||||
unsigned int index;
|
||||
unsigned char found;
|
||||
|
@ -251,7 +251,7 @@ _efl_ui_exact_model_efl_model_property_set(Eo *obj, Efl_Ui_Exact_Model_Data *pd,
|
|||
pd->parent->total_size.width = pd->parent->slot[found].width[index % EFL_UI_EXACT_MODEL_CONTENT];
|
||||
return efl_loop_future_resolved(obj, eina_value_uint_init(pd->parent->slot[found].width[index % EFL_UI_EXACT_MODEL_CONTENT]));
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_selfh))
|
||||
if (eina_streq(property, _efl_model_property_selfh))
|
||||
{
|
||||
unsigned int old_value;
|
||||
unsigned int index;
|
||||
|
@ -267,23 +267,23 @@ _efl_ui_exact_model_efl_model_property_set(Eo *obj, Efl_Ui_Exact_Model_Data *pd,
|
|||
return efl_loop_future_resolved(obj, eina_value_uint_init(pd->parent->slot[found].height[index % EFL_UI_EXACT_MODEL_CONTENT]));
|
||||
}
|
||||
// The following property are calculated by the model and so READ_ONLY
|
||||
if (!strcmp(property, _efl_model_property_totalh))
|
||||
if (eina_streq(property, _efl_model_property_totalh))
|
||||
{
|
||||
return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_READ_ONLY);
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_totalw))
|
||||
if (eina_streq(property, _efl_model_property_totalw))
|
||||
{
|
||||
return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_READ_ONLY);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(property, _efl_model_property_itemw))
|
||||
if (eina_streq(property, _efl_model_property_itemw))
|
||||
{
|
||||
// The exact model can not guess a general item size if asked
|
||||
// and should refuse to remember anything like that.
|
||||
return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_READ_ONLY);
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_itemh))
|
||||
if (eina_streq(property, _efl_model_property_itemh))
|
||||
{
|
||||
// The exact model can not guess a general item size if asked
|
||||
// and should refuse to remember anything like that.
|
||||
|
@ -299,7 +299,7 @@ _efl_ui_exact_model_efl_model_property_get(const Eo *obj, Efl_Ui_Exact_Model_Dat
|
|||
{
|
||||
if (pd->parent)
|
||||
{
|
||||
if (!strcmp(property, _efl_model_property_selfw))
|
||||
if (eina_streq(property, _efl_model_property_selfw))
|
||||
{
|
||||
unsigned int index;
|
||||
unsigned char found;
|
||||
|
@ -308,7 +308,7 @@ _efl_ui_exact_model_efl_model_property_get(const Eo *obj, Efl_Ui_Exact_Model_Dat
|
|||
found = _efl_ui_exact_model_slot_find(pd, index, EINA_TRUE, EINA_FALSE);
|
||||
return eina_value_uint_new(pd->parent->slot[found].width[index % EFL_UI_EXACT_MODEL_CONTENT]);
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_selfh))
|
||||
if (eina_streq(property, _efl_model_property_selfh))
|
||||
{
|
||||
unsigned int index;
|
||||
unsigned char found;
|
||||
|
@ -318,20 +318,20 @@ _efl_ui_exact_model_efl_model_property_get(const Eo *obj, Efl_Ui_Exact_Model_Dat
|
|||
return eina_value_uint_new(pd->parent->slot[found].height[index % EFL_UI_EXACT_MODEL_CONTENT]);
|
||||
}
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_totalh))
|
||||
if (eina_streq(property, _efl_model_property_totalh))
|
||||
{
|
||||
return eina_value_uint_new(pd->total_size.height);
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_totalw))
|
||||
if (eina_streq(property, _efl_model_property_totalw))
|
||||
{
|
||||
return eina_value_uint_new(pd->total_size.width);
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_itemw))
|
||||
if (eina_streq(property, _efl_model_property_itemw))
|
||||
{
|
||||
// The exact model can not guess a general item size if asked.
|
||||
return eina_value_error_new(EAGAIN);
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_itemh))
|
||||
if (eina_streq(property, _efl_model_property_itemh))
|
||||
{
|
||||
// The exact model can not guess a general item size if asked.
|
||||
return eina_value_error_new(EAGAIN);
|
||||
|
|
|
@ -46,25 +46,25 @@ _efl_ui_homogeneous_model_efl_model_property_set(Eo *obj,
|
|||
{
|
||||
if (pd->parent)
|
||||
{
|
||||
if (!strcmp(property, _efl_model_property_selfw))
|
||||
if (eina_streq(property, _efl_model_property_selfw))
|
||||
return _efl_ui_homogeneous_model_property_set(obj, value,
|
||||
&pd->parent->item.defined.width,
|
||||
&pd->parent->item.width);
|
||||
if (!strcmp(property, _efl_model_property_selfh))
|
||||
if (eina_streq(property, _efl_model_property_selfh))
|
||||
return _efl_ui_homogeneous_model_property_set(obj, value,
|
||||
&pd->parent->item.defined.height,
|
||||
&pd->parent->item.height);
|
||||
if (!strcmp(property, _efl_model_property_totalw) ||
|
||||
!strcmp(property, _efl_model_property_totalh))
|
||||
if (eina_streq(property, _efl_model_property_totalw) ||
|
||||
eina_streq(property, _efl_model_property_totalh))
|
||||
return efl_loop_future_rejected(obj, EFL_MODEL_ERROR_READ_ONLY);
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_itemw))
|
||||
if (eina_streq(property, _efl_model_property_itemw))
|
||||
{
|
||||
return _efl_ui_homogeneous_model_property_set(obj, value,
|
||||
&pd->item.defined.width,
|
||||
&pd->item.width);
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_itemh))
|
||||
if (eina_streq(property, _efl_model_property_itemh))
|
||||
{
|
||||
return _efl_ui_homogeneous_model_property_set(obj, value,
|
||||
&pd->item.defined.height,
|
||||
|
@ -82,39 +82,39 @@ _efl_ui_homogeneous_model_efl_model_property_get(const Eo *obj,
|
|||
{
|
||||
if (pd->parent)
|
||||
{
|
||||
if (!strcmp(property, _efl_model_property_selfw))
|
||||
if (eina_streq(property, _efl_model_property_selfw))
|
||||
{
|
||||
if (pd->parent->item.defined.width)
|
||||
return eina_value_uint_new(pd->parent->item.width);
|
||||
goto not_ready;
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_selfh))
|
||||
if (eina_streq(property, _efl_model_property_selfh))
|
||||
{
|
||||
if (pd->parent->item.defined.height)
|
||||
return eina_value_uint_new(pd->parent->item.height);
|
||||
goto not_ready;
|
||||
}
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_itemw))
|
||||
if (eina_streq(property, _efl_model_property_itemw))
|
||||
{
|
||||
if (pd->item.defined.width)
|
||||
return eina_value_uint_new(pd->item.width);
|
||||
goto not_ready;
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_itemh))
|
||||
if (eina_streq(property, _efl_model_property_itemh))
|
||||
{
|
||||
if (pd->item.defined.height)
|
||||
return eina_value_uint_new(pd->item.height);
|
||||
goto not_ready;
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_totalh))
|
||||
if (eina_streq(property, _efl_model_property_totalh))
|
||||
{
|
||||
if (pd->item.defined.height)
|
||||
return eina_value_uint_new(pd->item.height *
|
||||
efl_model_children_count_get(obj));
|
||||
goto not_ready;
|
||||
}
|
||||
if (!strcmp(property, _efl_model_property_totalw))
|
||||
if (eina_streq(property, _efl_model_property_totalw))
|
||||
{
|
||||
if (pd->item.defined.width)
|
||||
// We only handle vertical list at this point, so total width is the width of one item.
|
||||
|
|
Loading…
Reference in New Issue