[3.x] Fix crashes when using _input functions

This commit is contained in:
Rafał Mikrut 2021-04-27 16:51:29 +02:00
parent 2d57df60f7
commit 06976c3e84
15 changed files with 18 additions and 1 deletions

View file

@ -597,6 +597,7 @@ void AnimationBezierTrackEdit::_select_at_anim(const Ref<Animation> &p_anim, int
} }
void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
if (p_event->is_pressed()) { if (p_event->is_pressed()) {
if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->is_shortcut(p_event)) { if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->is_shortcut(p_event)) {

View file

@ -2654,6 +2654,8 @@ String AnimationTrackEdit::get_tooltip(const Point2 &p_pos) const {
} }
void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
if (p_event->is_pressed()) { if (p_event->is_pressed()) {
if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->is_shortcut(p_event)) { if (ED_GET_SHORTCUT("animation_editor/duplicate_selection")->is_shortcut(p_event)) {
emit_signal("duplicate_request"); emit_signal("duplicate_request");

View file

@ -58,7 +58,6 @@ void EditorHelp::_init_colors() {
} }
void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) { void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
if (!is_visible_in_tree()) if (!is_visible_in_tree())
return; return;

View file

@ -1265,6 +1265,7 @@ void AnimationPlayerEditor::_onion_skinning_menu(int p_option) {
} }
void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { void AnimationPlayerEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
ERR_FAIL_COND(p_ev.is_null());
Ref<InputEventKey> k = p_ev; Ref<InputEventKey> k = p_ev;
if (is_visible_in_tree() && k.is_valid() && k->is_pressed() && !k->is_echo() && !k->get_alt() && !k->get_control() && !k->get_metakey()) { if (is_visible_in_tree() && k.is_valid() && k->is_pressed() && !k->is_echo() && !k->get_alt() && !k->get_control() && !k->get_metakey()) {

View file

@ -468,6 +468,7 @@ float CanvasItemEditor::snap_angle(float p_target, float p_start) const {
} }
void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) { void CanvasItemEditor::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
ERR_FAIL_COND(p_ev.is_null());
Ref<InputEventKey> k = p_ev; Ref<InputEventKey> k = p_ev;

View file

@ -2641,6 +2641,8 @@ void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Co
} }
void ScriptEditor::_unhandled_input(const Ref<InputEvent> &p_event) { void ScriptEditor::_unhandled_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo()) if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo())
return; return;
if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) { if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) {

View file

@ -6023,6 +6023,7 @@ void SpatialEditor::snap_selected_nodes_to_floor() {
} }
void SpatialEditor::_unhandled_key_input(Ref<InputEvent> p_event) { void SpatialEditor::_unhandled_key_input(Ref<InputEvent> p_event) {
ERR_FAIL_COND(p_event.is_null());
if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack()) if (!is_visible_in_tree() || get_viewport()->gui_has_modal_stack())
return; return;

View file

@ -70,6 +70,7 @@ void SceneTreeDock::_input(Ref<InputEvent> p_event) {
} }
void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) { void SceneTreeDock::_unhandled_key_input(Ref<InputEvent> p_event) {
ERR_FAIL_COND(p_event.is_null());
if (get_viewport()->get_modal_stack_top()) if (get_viewport()->get_modal_stack_top())
return; //ignore because of modal window return; //ignore because of modal window

View file

@ -191,6 +191,7 @@ String TouchScreenButton::get_action() const {
} }
void TouchScreenButton::_input(const Ref<InputEvent> &p_event) { void TouchScreenButton::_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
if (!get_tree()) if (!get_tree())
return; return;

View file

@ -52,6 +52,7 @@ void BaseButton::_unpress_group() {
} }
void BaseButton::_gui_input(Ref<InputEvent> p_event) { void BaseButton::_gui_input(Ref<InputEvent> p_event) {
ERR_FAIL_COND(p_event.is_null());
if (status.disabled) // no interaction with disabled button if (status.disabled) // no interaction with disabled button
return; return;
@ -355,6 +356,7 @@ Ref<ShortCut> BaseButton::get_shortcut() const {
} }
void BaseButton::_unhandled_input(Ref<InputEvent> p_event) { void BaseButton::_unhandled_input(Ref<InputEvent> p_event) {
ERR_FAIL_COND(p_event.is_null());
if (!is_disabled() && is_visible_in_tree() && !p_event->is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) { if (!is_disabled() && is_visible_in_tree() && !p_event->is_echo() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {

View file

@ -471,6 +471,7 @@ Size2 ItemList::Item::get_icon_size() const {
} }
void ItemList::_gui_input(const Ref<InputEvent> &p_event) { void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
double prev_scroll = scroll_bar->get_value(); double prev_scroll = scroll_bar->get_value();

View file

@ -33,6 +33,7 @@
#include "scene/main/viewport.h" #include "scene/main/viewport.h"
void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) { void MenuButton::_unhandled_key_input(Ref<InputEvent> p_event) {
ERR_FAIL_COND(p_event.is_null());
if (disable_shortcuts) if (disable_shortcuts)
return; return;

View file

@ -214,6 +214,7 @@ void PopupMenu::_scroll(float p_factor, const Point2 &p_over) {
} }
void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
if (p_event->is_action("ui_down") && p_event->is_pressed()) { if (p_event->is_action("ui_down") && p_event->is_pressed()) {

View file

@ -42,6 +42,7 @@ void ScrollBar::set_can_focus_by_default(bool p_can_focus) {
} }
void ScrollBar::_gui_input(Ref<InputEvent> p_event) { void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
ERR_FAIL_COND(p_event.is_null());
Ref<InputEventMouseMotion> m = p_event; Ref<InputEventMouseMotion> m = p_event;
if (!m.is_valid() || drag.active) { if (!m.is_valid() || drag.active) {

View file

@ -143,6 +143,7 @@ void ViewportContainer::_notification(int p_what) {
} }
void ViewportContainer::_input(const Ref<InputEvent> &p_event) { void ViewportContainer::_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
if (Engine::get_singleton()->is_editor_hint()) if (Engine::get_singleton()->is_editor_hint())
return; return;
@ -168,6 +169,7 @@ void ViewportContainer::_input(const Ref<InputEvent> &p_event) {
} }
void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) { void ViewportContainer::_unhandled_input(const Ref<InputEvent> &p_event) {
ERR_FAIL_COND(p_event.is_null());
if (Engine::get_singleton()->is_editor_hint()) if (Engine::get_singleton()->is_editor_hint())
return; return;