Stop processing no context node inputs when the input gets handled. Also use ObjectIDs in case Nodes get deleted.

This commit is contained in:
Relintai 2023-09-09 03:41:19 +02:00
parent 041de5607e
commit 93f4077e73

View File

@ -1280,8 +1280,6 @@ void SceneTree::_call_input_pause(const StringName &p_group, const CallInputType
call_lock++;
_THREAD_SAFE_UNLOCK_
Vector<Node *> 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<ObjectID> 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<Node>(ObjectDB::get_instance(no_context_node_ids[i]));
if (n) {
n->call_multilevel(method, (const Variant **)v, 1);
}
}
}