elementary: make sure that our index for the maximum number of object is actually unsigned int bound.

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10927
This commit is contained in:
Cedric BAIL 2019-12-19 10:47:57 -08:00 committed by Marcel Hollerbach
parent 6756485476
commit 4624b56bed
5 changed files with 40 additions and 40 deletions

View File

@ -1208,8 +1208,9 @@ _efl_ui_collection_focus_manager_efl_ui_focus_manager_request_move(Eo *obj, Efl_
if (ITEM_IS_OUTSIDE_VISIBLE(item_id))
{
int new_id = efl_ui_position_manager_entity_relative_item(collection_pd->pos_man, efl_ui_item_index_get(item), direction);
if (new_id == -1)
unsigned int new_id;
if (!efl_ui_position_manager_entity_relative_item(collection_pd->pos_man, efl_ui_item_index_get(item), direction, &new_id))
{
new_item = NULL;
}

View File

@ -2430,12 +2430,12 @@ _efl_ui_collection_view_focus_manager_efl_ui_focus_manager_request_move(Eo *obj,
if (ITEM_IS_OUTSIDE_VISIBLE(item_id))
{
int new_id;
unsigned int new_id;
new_id = efl_ui_position_manager_entity_relative_item(cpd->manager,
item_id,
direction);
if (new_id < 0)
if (!efl_ui_position_manager_entity_relative_item(cpd->manager,
item_id,
direction,
&new_id))
{
new_item = NULL;
}

View File

@ -107,8 +107,9 @@ interface @beta Efl.Ui.Position_Manager.Entity extends Efl.Ui.Layout_Orientable
params {
current_id : uint; [[The id where the direction is oriented at]]
direction : Efl.Ui.Focus.Direction; [[The direction where the new id is]]
@out index: uint; [[The relative item index after the translation has been applied.]]
}
return : int; [[The id of the item in that direction, or -1 if there is no item in that direction]]
return : bool; [[$true if there is a next item, $false otherwise.]]
}
}
events {

View File

@ -738,35 +738,34 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_entity_position_single_ite
return geom;
}
EOLIAN static int
_efl_ui_position_manager_grid_efl_ui_position_manager_entity_relative_item(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd, unsigned int current_id, Efl_Ui_Focus_Direction direction)
EOLIAN static Eina_Bool
_efl_ui_position_manager_grid_efl_ui_position_manager_entity_relative_item(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd, unsigned int current_id, Efl_Ui_Focus_Direction direction, unsigned int *index)
{
int new_id = current_id;
switch(direction)
{
case EFL_UI_FOCUS_DIRECTION_RIGHT:
case EFL_UI_FOCUS_DIRECTION_NEXT:
new_id += 1;
break;
if (current_id + 1 >= pd->size) return EINA_FALSE;
current_id += 1;
break;
case EFL_UI_FOCUS_DIRECTION_LEFT:
case EFL_UI_FOCUS_DIRECTION_PREVIOUS:
new_id -= 1;
break;
if (current_id == 0) return EINA_FALSE;
current_id -= 1;
break;
case EFL_UI_FOCUS_DIRECTION_UP:
//FIXME
break;
//FIXME
break;
case EFL_UI_FOCUS_DIRECTION_DOWN:
//FIXME
break;
//FIXME
break;
default:
new_id = -1;
ERR("Uncaught case!");
break;
ERR("Uncaught case!");
return EINA_FALSE;
}
if (new_id < 0 || new_id > (int)pd->size)
return -1;
else
return new_id;
if (index) *index = current_id;
return EINA_TRUE;
}
EOLIAN static int

View File

@ -520,31 +520,30 @@ _efl_ui_position_manager_list_efl_object_invalidate(Eo *obj, Efl_Ui_Position_Man
efl_invalidate(efl_super(obj, MY_CLASS));
}
EOLIAN static int
_efl_ui_position_manager_list_efl_ui_position_manager_entity_relative_item(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd, unsigned int current_id, Efl_Ui_Focus_Direction direction)
EOLIAN static Eina_Bool
_efl_ui_position_manager_list_efl_ui_position_manager_entity_relative_item(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd, unsigned int current_id, Efl_Ui_Focus_Direction direction, unsigned int *index)
{
int new_id = current_id;
switch(direction)
{
case EFL_UI_FOCUS_DIRECTION_RIGHT:
case EFL_UI_FOCUS_DIRECTION_NEXT:
case EFL_UI_FOCUS_DIRECTION_DOWN:
new_id += 1;
break;
if (current_id + 1 >= pd->size) return EINA_FALSE;
current_id += 1;
break;
case EFL_UI_FOCUS_DIRECTION_LEFT:
case EFL_UI_FOCUS_DIRECTION_PREVIOUS:
case EFL_UI_FOCUS_DIRECTION_UP:
new_id -= 1;
break;
if (current_id == 0) return EINA_FALSE;
current_id -= 1;
break;
default:
ERR("Uncaught case!");
new_id = -1;
break;
ERR("Uncaught case!");
return EINA_FALSE;
}
if (new_id < 0 || new_id > (int)pd->size)
return -1;
else
return new_id;
if (index) *index = current_id;
return EINA_TRUE;
}
EOLIAN static int