From d159123633beb756c923d1dbb3faee6657269b2c Mon Sep 17 00:00:00 2001 From: kleonc <9283098+kleonc@users.noreply.github.com> Date: Wed, 29 Mar 2023 14:52:16 +0200 Subject: [PATCH] Fix recursive Node.find_children --- scene/main/node.cpp | 26 ++++++++++---------------- tests/scene/test_node.h | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 22bcfc947bd4..6ca34e324c3d 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1414,25 +1414,19 @@ TypedArray Node::find_children(const String &p_pattern, const String &p_ty continue; } - if (!p_pattern.is_empty()) { - if (!cptr[i]->data.name.operator String().match(p_pattern)) { - continue; - } else if (p_type.is_empty()) { + if (p_pattern.is_empty() || cptr[i]->data.name.operator String().match(p_pattern)) { + if (p_type.is_empty() || cptr[i]->is_class(p_type)) { ret.append(cptr[i]); - } - } + } else if (cptr[i]->get_script_instance()) { + Ref