Skip to content

Commit

Permalink
Fix find_next_valid_focus() freeze
Browse files Browse the repository at this point in the history
(cherry picked from commit d9ede52)
  • Loading branch information
KoBeWi authored and akien-mga committed Jun 30, 2022
1 parent 9e165a8 commit f659869
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions scene/gui/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ void Control::set_focus_mode(FocusMode p_focus_mode) {

static Control *_next_control(Control *p_from) {
if (p_from->is_set_as_toplevel()) {
return nullptr; // can't go above
return nullptr; // Can't go above.
}

Control *parent = Object::cast_to<Control>(p_from->get_parent());
Expand All @@ -1845,7 +1845,7 @@ static Control *_next_control(Control *p_from) {
return c;
}

//no next in parent, try the same in parent
// No next in parent, try the same in parent.
return _next_control(parent);
}

Expand All @@ -1869,7 +1869,7 @@ Control *Control::find_next_valid_focus() const {
}
}

// find next child
// Find next child.

Control *next_child = nullptr;

Expand All @@ -1885,7 +1885,7 @@ Control *Control::find_next_valid_focus() const {

if (!next_child) {
next_child = _next_control(from);
if (!next_child) { //nothing else.. go up and find either window or subwindow
if (!next_child) { // Nothing else. Go up and find either window or subwindow.
next_child = const_cast<Control *>(this);
while (next_child && !next_child->is_set_as_toplevel()) {
next_child = cast_to<Control>(next_child->get_parent());
Expand All @@ -1903,7 +1903,7 @@ Control *Control::find_next_valid_focus() const {
}
}

if (next_child == this) { // no next control->
if (next_child == from) { // No next control.
return (get_focus_mode() == FOCUS_ALL) ? next_child : nullptr;
}
if (next_child) {
Expand Down Expand Up @@ -1935,7 +1935,7 @@ static Control *_prev_control(Control *p_from) {
return p_from;
}

//no prev in parent, try the same in parent
// No prev in parent, try the same in parent.
return _prev_control(child);
}

Expand All @@ -1959,12 +1959,12 @@ Control *Control::find_prev_valid_focus() const {
}
}

// find prev child
// Find prev child.

Control *prev_child = nullptr;

if (from->is_set_as_toplevel() || !Object::cast_to<Control>(from->get_parent())) {
//find last of the children
// Find last of the children.

prev_child = _prev_control(from);

Expand All @@ -1987,7 +1987,7 @@ Control *Control::find_prev_valid_focus() const {
}
}

if (prev_child == this) { // no prev control->
if (prev_child == from) { // No prev control.
return (get_focus_mode() == FOCUS_ALL) ? prev_child : nullptr;
}

Expand Down

0 comments on commit f659869

Please sign in to comment.