Merge pull request #40160 from pycbouh/fix-pnode-is-null

Improve null check in FindReplaceBar
This commit is contained in:
Rémi Verschelde 2020-07-06 23:47:44 +02:00 committed by GitHub
commit f706156329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
if (!k.is_valid() || !k->is_pressed()) {
return;
}
switch (k->get_keycode()) {
case KEY_ESCAPE: {
_hide_bar();
} break;
default: {
accepted = false;
} break;
}
Control *focus_owner = get_focus_owner();
if (text_edit->has_focus() || (focus_owner && vbc_lineedit->is_a_parent_of(focus_owner))) {
bool accepted = true;
if (accepted) {
accept_event();
}
switch (k->get_keycode()) {
case KEY_ESCAPE: {
_hide_bar();
} break;
default: {
accepted = false;
} break;
}
if (accepted) {
accept_event();
}
}
}