Browse Source

Merge pull request #69246 from nongvantinh/3.x-check-null-for-input_event

3.x Enhance null checking for input event
Rémi Verschelde 2 years ago
parent
commit
6f91639af2

+ 2 - 0
scene/gui/dialogs.cpp

@@ -106,6 +106,8 @@ bool WindowDialog::has_point(const Point2 &p_point) const {
 }
 
 void WindowDialog::_gui_input(const Ref<InputEvent> &p_event) {
+	ERR_FAIL_COND(p_event.is_null());
+
 	Ref<InputEventMouseButton> mb = p_event;
 
 	if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT) {

+ 2 - 0
scene/gui/file_dialog.cpp

@@ -78,6 +78,8 @@ void FileDialog::_notification(int p_what) {
 }
 
 void FileDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
+	ERR_FAIL_COND(p_event.is_null());
+
 	Ref<InputEventKey> k = p_event;
 	if (k.is_valid() && is_window_modal_on_top()) {
 		if (k->is_pressed()) {

+ 2 - 0
scene/gui/graph_edit.cpp

@@ -1098,6 +1098,8 @@ void GraphEdit::set_selected(Node *p_child) {
 }
 
 void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
+	ERR_FAIL_COND(p_ev.is_null());
+
 	Ref<InputEventMouseMotion> mm = p_ev;
 	if (mm.is_valid() && (mm->get_button_mask() & BUTTON_MASK_MIDDLE || (mm->get_button_mask() & BUTTON_MASK_LEFT && Input::get_singleton()->is_key_pressed(KEY_SPACE)))) {
 		Vector2i relative = Input::get_singleton()->warp_mouse_motion(mm, get_global_rect());

+ 2 - 0
scene/gui/graph_node.cpp

@@ -746,6 +746,8 @@ Color GraphNode::get_connection_output_color(int p_idx) {
 }
 
 void GraphNode::_gui_input(const Ref<InputEvent> &p_ev) {
+	ERR_FAIL_COND(p_ev.is_null());
+
 	Ref<InputEventMouseButton> mb = p_ev;
 	if (mb.is_valid()) {
 		ERR_FAIL_COND_MSG(get_parent_control() == nullptr, "GraphNode must be the child of a GraphEdit node.");

+ 2 - 0
scene/gui/line_edit.cpp

@@ -49,6 +49,8 @@ static bool _is_text_char(CharType c) {
 }
 
 void LineEdit::_gui_input(Ref<InputEvent> p_event) {
+	ERR_FAIL_COND(p_event.is_null());
+
 	Ref<InputEventMouseButton> b = p_event;
 
 	if (b.is_valid()) {

+ 2 - 0
scene/gui/rich_text_label.cpp

@@ -1164,6 +1164,8 @@ Control::CursorShape RichTextLabel::get_cursor_shape(const Point2 &p_pos) const
 }
 
 void RichTextLabel::_gui_input(Ref<InputEvent> p_event) {
+	ERR_FAIL_COND(p_event.is_null());
+
 	Ref<InputEventMouseButton> b = p_event;
 
 	if (b.is_valid()) {

+ 2 - 0
scene/gui/scroll_container.cpp

@@ -88,6 +88,8 @@ void ScrollContainer::_cancel_drag() {
 }
 
 void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) {
+	ERR_FAIL_COND(p_gui_input.is_null());
+
 	double prev_v_scroll = v_scroll->get_value();
 	double prev_h_scroll = h_scroll->get_value();
 

+ 2 - 0
scene/gui/slider.cpp

@@ -46,6 +46,8 @@ Size2 Slider::get_minimum_size() const {
 }
 
 void Slider::_gui_input(Ref<InputEvent> p_event) {
+	ERR_FAIL_COND(p_event.is_null());
+
 	if (!editable) {
 		return;
 	}

+ 2 - 0
scene/gui/spin_box.cpp

@@ -101,6 +101,8 @@ void SpinBox::_release_mouse() {
 }
 
 void SpinBox::_gui_input(const Ref<InputEvent> &p_event) {
+	ERR_FAIL_COND(p_event.is_null());
+
 	if (!is_editable()) {
 		return;
 	}

+ 2 - 0
scene/gui/split_container.cpp

@@ -196,6 +196,8 @@ void SplitContainer::_notification(int p_what) {
 }
 
 void SplitContainer::_gui_input(const Ref<InputEvent> &p_event) {
+	ERR_FAIL_COND(p_event.is_null());
+
 	if (collapsed || !_getch(0) || !_getch(1) || dragger_visibility != DRAGGER_VISIBLE) {
 		return;
 	}

+ 2 - 0
scene/gui/tab_container.cpp

@@ -69,6 +69,8 @@ int TabContainer::_get_top_margin() const {
 }
 
 void TabContainer::_gui_input(const Ref<InputEvent> &p_event) {
+	ERR_FAIL_COND(p_event.is_null());
+
 	Ref<InputEventMouseButton> mb = p_event;
 
 	Popup *popup = get_popup();

+ 2 - 0
scene/gui/tabs.cpp

@@ -84,6 +84,8 @@ Size2 Tabs::get_minimum_size() const {
 }
 
 void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
+	ERR_FAIL_COND(p_event.is_null());
+
 	Ref<InputEventMouseMotion> mm = p_event;
 
 	if (mm.is_valid()) {

+ 2 - 0
scene/gui/text_edit.cpp

@@ -2402,6 +2402,8 @@ void TextEdit::_get_minimap_mouse_row(const Point2i &p_mouse, int &r_row) const
 }
 
 void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
+	ERR_FAIL_COND(p_gui_input.is_null());
+
 	double prev_v_scroll = v_scroll->get_value();
 	double prev_h_scroll = h_scroll->get_value();
 

+ 4 - 0
scene/main/viewport.cpp

@@ -1414,6 +1414,8 @@ void Viewport::_vp_input_text(const String &p_text) {
 }
 
 void Viewport::_vp_input(const Ref<InputEvent> &p_ev) {
+	ERR_FAIL_COND(p_ev.is_null());
+
 	if (disable_input) {
 		return;
 	}
@@ -1436,6 +1438,8 @@ void Viewport::_vp_input(const Ref<InputEvent> &p_ev) {
 }
 
 void Viewport::_vp_unhandled_input(const Ref<InputEvent> &p_ev) {
+	ERR_FAIL_COND(p_ev.is_null());
+
 	if (disable_input) {
 		return;
 	}