efl_ui_focus_manager_calc: fix infinite loop in _request_subchild

When the subchild where we request subchilds from was regular, the while
loop would have run infinitly. This is now fixed by at least calling
once _next, the check to not run outside the node is now done with
calculating the depth of the nodes.
This commit is contained in:
Marcel Hollerbach 2018-04-03 13:55:51 +02:00
parent 36d9fdc770
commit 7fe52c55cf
1 changed files with 21 additions and 4 deletions

View File

@ -1511,6 +1511,20 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_request_move(Eo *obj EINA_UNUSED
}
}
static int
_node_depth(Node *node)
{
int i = 0;
while (node->tree.parent)
{
node = node->tree.parent;
i++;
}
return i;
}
static Node*
_request_subchild(Node *node)
{
@ -1519,19 +1533,22 @@ _request_subchild(Node *node)
if (node->tree.children)
{
target = node;
int new_depth, old_depth = _node_depth(node);
target = node;
//try to find a child that is not logical or has a redirect manager
while (target && target->type == NODE_TYPE_ONLY_LOGICAL && !target->redirect_manager)
do
{
if (target != node)
efl_ui_focus_object_prepare_logical(target->focusable);
target = _next(target);
//abort if we are exceeding the childrens of node
if (target == node) target = NULL;
}
new_depth = _node_depth(target);
if (new_depth <= old_depth) target = NULL;
}
while (target && target->type == NODE_TYPE_ONLY_LOGICAL && !target->redirect_manager);
F_DBG("Found node %p", target);
}