bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7fe52c55cfd3ef95801e166cbbf387ad016dcd90

commit 7fe52c55cfd3ef95801e166cbbf387ad016dcd90
Author: Marcel Hollerbach <[email protected]>
Date:   Tue Apr 3 13:55:51 2018 +0200

    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.
---
 src/lib/elementary/efl_ui_focus_manager_calc.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/lib/elementary/efl_ui_focus_manager_calc.c 
b/src/lib/elementary/efl_ui_focus_manager_calc.c
index 9dd1b98e89..381bc77755 100644
--- a/src/lib/elementary/efl_ui_focus_manager_calc.c
+++ b/src/lib/elementary/efl_ui_focus_manager_calc.c
@@ -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);
      }
 

-- 


Reply via email to