From 8dd026e4f91f802719315fb6b5a45e36723d3adc Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Wed, 5 Oct 2016 08:56:58 +0200 Subject: [PATCH] Prevent crash on focus change when no valid next control has been found. Fixes the crash discussed in #6714. --- scene/gui/control.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index a5bee32a69d..97f0db97c2c 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1725,11 +1725,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;