From d3e4db4a7b924720089adfc216e3f4bd959fb34b Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 1 Jun 2023 20:49:39 -0500 Subject: [PATCH] Fix crash when removing SpinBox during text submit --- scene/gui/spin_box.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index a0c8f7c91f2..d0f0d655989 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -202,7 +202,8 @@ void SpinBox::_line_edit_focus_enter() { void SpinBox::_line_edit_focus_exit() { // Discontinue because the focus_exit was caused by left-clicking the arrows. - if (get_viewport()->gui_get_focus_owner() == get_line_edit()) { + Viewport *viewport = get_viewport(); + if (!viewport || viewport->gui_get_focus_owner() == get_line_edit()) { return; } // Discontinue because the focus_exit was caused by right-click context menu.