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

3.x Enhance null checking for input event
This commit is contained in:
Rémi Verschelde 2022-11-28 13:21:22 +01:00
commit 6f91639af2
No known key found for this signature in database
GPG Key ID: C3336907360768E1
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) {
ERR_FAIL_COND(p_event.is_null());
Ref<InputEventMouseButton> mb = p_event;
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) {
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()) {

View File

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

View File

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

View File

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

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) {
ERR_FAIL_COND(p_event.is_null());
Ref<InputEventMouseButton> b = p_event;
if (b.is_valid()) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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) {
ERR_FAIL_COND(p_gui_input.is_null());
double prev_v_scroll = v_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) {
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;
}