diff options
| author | Rémi Verschelde <remi@verschelde.fr> | 2023-06-23 22:45:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-23 22:45:51 +0200 |
| commit | afe65de11001b392cb9666b1ee32ea6c4ecf10ff (patch) | |
| tree | 1243818003c6876e9ffc2927279bc2be45ff76c3 | |
| parent | 68193bee9a1f77427a13b92508d611b1e2110217 (diff) | |
| parent | f745299c36cfa0ae936e9d2ae829e8cca91956f0 (diff) | |
| download | redot-engine-afe65de11001b392cb9666b1ee32ea6c4ecf10ff.tar.gz | |
Merge pull request #78591 from ajreckof/Fix-crash-when-removing-child-during-focus-exit-
Fix crash when removing child during focus exit.
| -rw-r--r-- | scene/main/viewport.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index f9d02a83fa..e15a8e4870 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2427,10 +2427,12 @@ void Viewport::_gui_control_grab_focus(Control *p_control) { return; } get_tree()->call_group("_viewports", "_gui_remove_focus_for_window", (Node *)get_base_window()); - gui.key_focus = p_control; - emit_signal(SNAME("gui_focus_changed"), p_control); - p_control->notification(Control::NOTIFICATION_FOCUS_ENTER); - p_control->queue_redraw(); + if (p_control->is_inside_tree() && p_control->get_viewport() == this) { + gui.key_focus = p_control; + emit_signal(SNAME("gui_focus_changed"), p_control); + p_control->notification(Control::NOTIFICATION_FOCUS_ENTER); + p_control->queue_redraw(); + } } void Viewport::_gui_accept_event() { |
