From 3f57cb12b435f44d60ab813ba824b8bf7f44d5b3 Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Mon, 6 Jul 2020 17:13:04 +0300 Subject: [PATCH] Improve null check in FindReplaceBar (cherry picked from commit e94b8a6accfb07003ee75ba6f8aab4f7f54f070a) --- editor/code_editor.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index e586d4ba559..8d9c817d9dd 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -116,27 +116,25 @@ void FindReplaceBar::_notification(int p_what) { void FindReplaceBar::_unhandled_input(const Ref &p_event) { Ref k = p_event; - if (k.is_valid()) { + if (!k.is_valid() || !k->is_pressed()) { + return; + } - if (k->is_pressed() && (text_edit->has_focus() || vbc_lineedit->is_a_parent_of(get_focus_owner()))) { + Control *focus_owner = get_focus_owner(); + if (text_edit->has_focus() || (focus_owner && vbc_lineedit->is_a_parent_of(focus_owner))) { + bool accepted = true; - bool accepted = true; + switch (k->get_scancode()) { + case KEY_ESCAPE: { + _hide_bar(); + } break; + default: { + accepted = false; + } break; + } - switch (k->get_scancode()) { - - case KEY_ESCAPE: { - - _hide_bar(); - } break; - default: { - - accepted = false; - } break; - } - - if (accepted) { - accept_event(); - } + if (accepted) { + accept_event(); } } }