Enhance null checking for input event

This commit is contained in:
Nong Van Tinh 2022-11-27 15:01:34 +07:00
parent 4769aa4499
commit ffbaa7fff0
14 changed files with 30 additions and 0 deletions

View file

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

View file

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

View file

@ -1098,6 +1098,8 @@ void GraphEdit::set_selected(Node *p_child) {
} }
void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) {
ERR_FAIL_COND(p_ev.is_null());
Ref<InputEventMouseMotion> mm = p_ev; 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)))) { 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()); Vector2i relative = Input::get_singleton()->warp_mouse_motion(mm, get_global_rect());

View file

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

View file

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

View file

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

View file

@ -88,6 +88,8 @@ void ScrollContainer::_cancel_drag() {
} }
void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { 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_v_scroll = v_scroll->get_value();
double prev_h_scroll = h_scroll->get_value(); double prev_h_scroll = h_scroll->get_value();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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) { 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_v_scroll = v_scroll->get_value();
double prev_h_scroll = h_scroll->get_value(); double prev_h_scroll = h_scroll->get_value();

View file

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