summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuri Sizov <11782833+YuriSizov@users.noreply.github.com>2023-06-06 12:19:25 +0200
committerGitHub <noreply@github.com>2023-06-06 12:19:25 +0200
commit2e728e02cc293d8de145de6855705550bd7c88f8 (patch)
treed03bfb0d368ad4883bf42cd8ad1d002bc91fc11a
parentcb2f47885de72d9db20508243f1e926b80a940b8 (diff)
parentc4db21287097bbd82cd6efe943d449e5af35d01c (diff)
downloadredot-engine-2e728e02cc293d8de145de6855705550bd7c88f8.tar.gz
Merge pull request #77763 from RedworkDE/warning-dialog-crash
Prevent crashes when removing Viewport from scene tree in event handler
-rw-r--r--scene/main/viewport.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 8fcf9e84c4..ab3cd69492 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -2988,10 +2988,12 @@ void Viewport::push_input(const Ref<InputEvent> &p_event, bool p_local_coords) {
}
if (!is_input_handled()) {
+ ERR_FAIL_COND(!is_inside_tree());
get_tree()->_call_input_pause(input_group, SceneTree::CALL_INPUT_TYPE_INPUT, ev, this); //not a bug, must happen before GUI, order is _input -> gui input -> _unhandled input
}
if (!is_input_handled()) {
+ ERR_FAIL_COND(!is_inside_tree());
_gui_input_event(ev);
} else {
// Cleanup internal GUI state after accepting event during _input().
@@ -3036,16 +3038,19 @@ void Viewport::push_unhandled_input(const Ref<InputEvent> &p_event, bool p_local
void Viewport::_push_unhandled_input_internal(const Ref<InputEvent> &p_event) {
// Shortcut Input.
if (Object::cast_to<InputEventKey>(*p_event) != nullptr || Object::cast_to<InputEventShortcut>(*p_event) != nullptr || Object::cast_to<InputEventJoypadButton>(*p_event) != nullptr) {
+ ERR_FAIL_COND(!is_inside_tree());
get_tree()->_call_input_pause(shortcut_input_group, SceneTree::CALL_INPUT_TYPE_SHORTCUT_INPUT, p_event, this);
}
// Unhandled Input.
if (!is_input_handled()) {
+ ERR_FAIL_COND(!is_inside_tree());
get_tree()->_call_input_pause(unhandled_input_group, SceneTree::CALL_INPUT_TYPE_UNHANDLED_INPUT, p_event, this);
}
// Unhandled key Input - Used for performance reasons - This is called a lot less than _unhandled_input since it ignores MouseMotion, and to handle Unicode input with Alt / Ctrl modifiers after handling shortcuts.
if (!is_input_handled() && (Object::cast_to<InputEventKey>(*p_event) != nullptr)) {
+ ERR_FAIL_COND(!is_inside_tree());
get_tree()->_call_input_pause(unhandled_key_input_group, SceneTree::CALL_INPUT_TYPE_UNHANDLED_KEY_INPUT, p_event, this);
}