diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index c08e10b9ffe..7873117808a 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1688,11 +1688,11 @@ Control *Control::find_next_valid_focus() const { if (next_child==this) // no next control-> return (get_focus_mode()==FOCUS_ALL)?next_child:NULL; - - if (next_child->get_focus_mode()==FOCUS_ALL) - return next_child; - - from = next_child; + if (next_child) { + if (next_child->get_focus_mode()==FOCUS_ALL) + return next_child; + from = next_child; + } else break; } return NULL;