diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-12-16 08:24:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-16 08:24:49 +0100 |
commit | b72e4079f343d440d6721f6bd4066f26a33a743a (patch) | |
tree | 445e7923477e734e9acb0dd3ea8464a8edcfd4d6 | |
parent | c39aa2b2002337f8ffc07d7606c18dfa534cd8c5 (diff) | |
parent | 32939ccd3987057c49a226909c025a3df7219c82 (diff) |
Merge pull request #34374 from KoBeWi/thinking_out_of_the_loop
Prevent infinite loop when focus_next is invisible
-rw-r--r-- | scene/gui/control.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 8b4d5d4980..ccc658b0aa 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2012,14 +2012,15 @@ Control *Control::find_next_valid_focus() const { if (!data.focus_next.is_empty()) { Node *n = get_node(data.focus_next); + Control *c; if (n) { - from = Object::cast_to<Control>(n); - ERR_FAIL_COND_V_MSG(!from, NULL, "Next focus node is not a control: " + n->get_name() + "."); + c = Object::cast_to<Control>(n); + ERR_FAIL_COND_V_MSG(!c, NULL, "Next focus node is not a control: " + n->get_name() + "."); } else { return NULL; } - if (from->is_visible() && from->get_focus_mode() != FOCUS_NONE) - return from; + if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) + return c; } // find next child @@ -2102,14 +2103,15 @@ Control *Control::find_prev_valid_focus() const { if (!data.focus_prev.is_empty()) { Node *n = get_node(data.focus_prev); + Control *c; if (n) { - from = Object::cast_to<Control>(n); - ERR_FAIL_COND_V_MSG(!from, NULL, "Previous focus node is not a control: " + n->get_name() + "."); + c = Object::cast_to<Control>(n); + ERR_FAIL_COND_V_MSG(!c, NULL, "Previous focus node is not a control: " + n->get_name() + "."); } else { return NULL; } - if (from->is_visible() && from->get_focus_mode() != FOCUS_NONE) - return from; + if (c->is_visible() && c->get_focus_mode() != FOCUS_NONE) + return c; } // find prev child |