diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 4568fcb4a..5d918a525 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1280,8 +1280,6 @@ void SceneTree::_call_input_pause(const StringName &p_group, const CallInputType call_lock++; _THREAD_SAFE_UNLOCK_ - Vector no_context_nodes; - StringName method; switch (p_call_type) { @@ -1318,6 +1316,8 @@ void SceneTree::_call_input_pause(const StringName &p_group, const CallInputType //ERR_FAIL_COND(node_count != g.nodes.size()); } } else { + Vector no_context_node_ids; + for (int i = node_count - 1; i >= 0; i--) { if (input_handled) { break; @@ -1337,7 +1337,7 @@ void SceneTree::_call_input_pause(const StringName &p_group, const CallInputType // 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() == NULL) { - no_context_nodes.push_back(n); + no_context_node_ids.push_back(n->get_instance_id()); continue; } if (!c->is_focus_owner_in_shortcut_context()) { @@ -1349,11 +1349,17 @@ void SceneTree::_call_input_pause(const StringName &p_group, const CallInputType //ERR_FAIL_COND(node_count != g.nodes.size()); } - int ncns = no_context_nodes.size(); + int ncns = no_context_node_ids.size(); for (int i = 0; i < ncns; ++i) { - Node *n = no_context_nodes[i]; - n->call_multilevel(method, (const Variant **)v, 1); + if (input_handled) { + break; + } + + Node *n = Object::cast_to(ObjectDB::get_instance(no_context_node_ids[i])); + if (n) { + n->call_multilevel(method, (const Variant **)v, 1); + } } }