forked from enlightenment/efl
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:
parent
6756485476
commit
4624b56bed
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
if (!efl_ui_position_manager_entity_relative_item(cpd->manager,
|
||||
item_id,
|
||||
direction);
|
||||
if (new_id < 0)
|
||||
direction,
|
||||
&new_id))
|
||||
{
|
||||
new_item = NULL;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -738,19 +738,20 @@ _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;
|
||||
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;
|
||||
if (current_id == 0) return EINA_FALSE;
|
||||
current_id -= 1;
|
||||
break;
|
||||
case EFL_UI_FOCUS_DIRECTION_UP:
|
||||
//FIXME
|
||||
|
@ -759,14 +760,12 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_entity_relative_item(Eo *o
|
|||
//FIXME
|
||||
break;
|
||||
default:
|
||||
new_id = -1;
|
||||
ERR("Uncaught case!");
|
||||
break;
|
||||
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
|
||||
|
|
|
@ -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;
|
||||
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;
|
||||
if (current_id == 0) return EINA_FALSE;
|
||||
current_id -= 1;
|
||||
break;
|
||||
default:
|
||||
ERR("Uncaught case!");
|
||||
new_id = -1;
|
||||
break;
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue