From 22ccfc5a392811bedf605a1462f58019fa807ea7 Mon Sep 17 00:00:00 2001 From: kobewi Date: Fri, 20 Sep 2024 17:20:03 +0200 Subject: [PATCH] Print error on invalid call_group() calls --- scene/main/scene_tree.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 106130872db..71d91b970ee 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -302,11 +302,15 @@ void SceneTree::call_group_flagsp(uint32_t p_call_flags, const StringName &p_gro continue; } + Node *node = gr_nodes[i]; if (!(p_call_flags & GROUP_CALL_DEFERRED)) { Callable::CallError ce; - gr_nodes[i]->callp(p_function, p_args, p_argcount, ce); + node->callp(p_function, p_args, p_argcount, ce); + if (unlikely(ce.error != Callable::CallError::CALL_OK && ce.error != Callable::CallError::CALL_ERROR_INVALID_METHOD)) { + ERR_PRINT(vformat("Error calling group method on node \"%s\": %s.", node->get_name(), Variant::get_callable_error_text(Callable(node, p_function), p_args, p_argcount, ce))); + } } else { - MessageQueue::get_singleton()->push_callp(gr_nodes[i], p_function, p_args, p_argcount); + MessageQueue::get_singleton()->push_callp(node, p_function, p_args, p_argcount); } } @@ -316,11 +320,15 @@ void SceneTree::call_group_flagsp(uint32_t p_call_flags, const StringName &p_gro continue; } + Node *node = gr_nodes[i]; if (!(p_call_flags & GROUP_CALL_DEFERRED)) { Callable::CallError ce; - gr_nodes[i]->callp(p_function, p_args, p_argcount, ce); + node->callp(p_function, p_args, p_argcount, ce); + if (unlikely(ce.error != Callable::CallError::CALL_OK && ce.error != Callable::CallError::CALL_ERROR_INVALID_METHOD)) { + ERR_PRINT(vformat("Error calling group method on node \"%s\": %s.", node->get_name(), Variant::get_callable_error_text(Callable(node, p_function), p_args, p_argcount, ce))); + } } else { - MessageQueue::get_singleton()->push_callp(gr_nodes[i], p_function, p_args, p_argcount); + MessageQueue::get_singleton()->push_callp(node, p_function, p_args, p_argcount); } } }