efl_ui_relative_layout: prevent infinite loop in chain calculation

Test Plan:
test code
```
EAPI_MAIN int
elm_main(int argc, char **argv)
{
   Eo *win, *layout, *btn1, *btn2, *btn3;

   win =  efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get());
   layout = efl_add(EFL_UI_RELATIVE_LAYOUT_CLASS, win,
                    efl_content_set(win, efl_added));

   btn1 = efl_add(EFL_UI_BUTTON_CLASS, layout);
   btn2 = efl_add(EFL_UI_BUTTON_CLASS, layout);

   efl_ui_relative_layout_relation_right_set(layout, btn1, btn2, 0.0);
   efl_ui_relative_layout_relation_right_set(layout, btn2, btn1, 0.0);

   efl_ui_relative_layout_relation_left_set(layout, btn2, btn1, 1.0);
   efl_ui_relative_layout_relation_left_set(layout, btn1, btn2, 1.0);

   elm_run();
   return 0;
}
ELM_MAIN()
```

Reviewers: Jaehyun_Cho

Reviewed By: Jaehyun_Cho

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9032
This commit is contained in:
Yeongjong Lee 2019-05-29 17:24:30 +09:00 committed by Jaehyun Cho
parent e3a791c4b1
commit 56ab05660e
1 changed files with 9 additions and 1 deletions

View File

@ -218,7 +218,15 @@ _child_chain_calc(Efl_Ui_Relative_Layout_Child *child, Eina_Bool axis)
// find head
head = child;
while (head == head->calc.to[START]->calc.to[END])
head = head->calc.to[START];
{
head = head->calc.to[START];
if (head == child)
{
ERR("%c-axis circular dependency when calculating \"%s\"(%p).",
axis ? 'Y' : 'X', efl_class_name_get(child->obj), child->obj);
return EINA_TRUE;
}
}
//calculate weight_sum
aspect_type = !axis ? EFL_GFX_HINT_ASPECT_VERTICAL : EFL_GFX_HINT_ASPECT_HORIZONTAL;