diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-07-06 23:47:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-06 23:47:44 +0200 |
commit | f70615632938e6ac35e39418549980c6a2e3748b (patch) | |
tree | 72f3d3c2ba9a87888ccb94fe4b0904c8866b14fc | |
parent | b00e8ffb22256c7815a577c30f5294ca4dbdaf42 (diff) | |
parent | e94b8a6accfb07003ee75ba6f8aab4f7f54f070a (diff) |
Merge pull request #40160 from pycbouh/fix-pnode-is-null
Improve null check in FindReplaceBar
-rw-r--r-- | editor/code_editor.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index b73a27214d..70747b4956 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -108,22 +108,25 @@ void FindReplaceBar::_notification(int p_what) { void FindReplaceBar::_unhandled_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; - if (k.is_valid()) { - if (k->is_pressed() && (text_edit->has_focus() || vbc_lineedit->is_a_parent_of(get_focus_owner()))) { - bool accepted = true; - - switch (k->get_keycode()) { - case KEY_ESCAPE: { - _hide_bar(); - } break; - default: { - accepted = false; - } break; - } + if (!k.is_valid() || !k->is_pressed()) { + return; + } - if (accepted) { - accept_event(); - } + Control *focus_owner = get_focus_owner(); + if (text_edit->has_focus() || (focus_owner && vbc_lineedit->is_a_parent_of(focus_owner))) { + bool accepted = true; + + switch (k->get_keycode()) { + case KEY_ESCAPE: { + _hide_bar(); + } break; + default: { + accepted = false; + } break; + } + + if (accepted) { + accept_event(); } } } |