Browse Source

[3.x] Fix crashes when using _input functions

Rafał Mikrut 4 years ago
parent
commit
06976c3e84

+ 1 - 0
editor/animation_bezier_editor.cpp

@@ -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)) {

+ 2 - 0
editor/animation_track_editor.cpp

@@ -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");

+ 0 - 1
editor/editor_help.cpp

@@ -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;
 
 

+ 1 - 0
editor/plugins/animation_player_editor_plugin.cpp

@@ -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()) {

+ 1 - 0
editor/plugins/canvas_item_editor_plugin.cpp

@@ -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;
 
 

+ 2 - 0
editor/plugins/script_editor_plugin.cpp

@@ -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)) {

+ 1 - 0
editor/plugins/spatial_editor_plugin.cpp

@@ -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;

+ 1 - 0
editor/scene_tree_dock.cpp

@@ -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

+ 1 - 0
scene/2d/touch_screen_button.cpp

@@ -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;

+ 2 - 0
scene/gui/base_button.cpp

@@ -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)) {
 
 

+ 1 - 0
scene/gui/item_list.cpp

@@ -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();
 
 

+ 1 - 0
scene/gui/menu_button.cpp

@@ -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;

+ 1 - 0
scene/gui/popup_menu.cpp

@@ -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()) {
 
 

+ 1 - 0
scene/gui/scroll_bar.cpp

@@ -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) {

+ 2 - 0
scene/gui/viewport_container.cpp

@@ -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;