diff options
author | Clay John <claynjohn@gmail.com> | 2022-10-27 09:56:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-27 09:56:55 -0700 |
commit | 2f2c138b4499ef0a070c13e5cc242946a8db155f (patch) | |
tree | dba3fb339e01dbe1327b93c94a4a7dd5524abdac | |
parent | 5f575bf1fa3d1dc3ad50f1188e6ca0eff7a14ddf (diff) | |
parent | c77349ecb74f0bc0c6ed9424bb6da3117513922a (diff) |
Merge pull request #67926 from Rindbee/fix_call_shortcut_input
Fix calling `_call_shortcut_input` on a node that has been removed
-rw-r--r-- | scene/main/scene_tree.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 270e5b7025..5ff9a29792 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -896,7 +896,7 @@ void SceneTree::_call_input_pause(const StringName &p_group, CallInputType p_cal call_lock++; - Vector<Node *> no_context_nodes; + Vector<ObjectID> no_context_node_ids; // Nodes may be deleted due to this shortcut input. for (int i = gr_node_count - 1; i >= 0; i--) { if (p_viewport->is_input_handled()) { @@ -922,7 +922,7 @@ void SceneTree::_call_input_pause(const StringName &p_group, CallInputType p_cal // If calling shortcut input on a control, ensure it respects the shortcut context. // Shortcut context (based on focus) only makes sense for controls (UI), so don't need to worry about it for nodes if (c->get_shortcut_context() == nullptr) { - no_context_nodes.append(n); + no_context_node_ids.append(n->get_instance_id()); continue; } if (!c->is_focus_owner_in_shortcut_context()) { @@ -941,8 +941,11 @@ void SceneTree::_call_input_pause(const StringName &p_group, CallInputType p_cal } } - for (Node *n : no_context_nodes) { - n->_call_shortcut_input(p_input); + for (const ObjectID &id : no_context_node_ids) { + Node *n = Object::cast_to<Node>(ObjectDB::get_instance(id)); + if (n) { + n->_call_shortcut_input(p_input); + } } call_lock--; |