diff options
author | kleonc <9283098+kleonc@users.noreply.github.com> | 2023-03-29 14:52:16 +0200 |
---|---|---|
committer | kleonc <9283098+kleonc@users.noreply.github.com> | 2023-04-09 09:15:21 +0200 |
commit | d159123633beb756c923d1dbb3faee6657269b2c (patch) | |
tree | 737d786cdeccf9ce9a136912dbe61edb5df622cb /scene/main/node.cpp | |
parent | 23394bebed07e172f77601baedbd78fd4f423694 (diff) | |
download | redot-engine-d159123633beb756c923d1dbb3faee6657269b2c.tar.gz |
Fix recursive Node.find_children
Diffstat (limited to 'scene/main/node.cpp')
-rw-r--r-- | scene/main/node.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 22bcfc947b..6ca34e324c 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1414,25 +1414,19 @@ TypedArray<Node> 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<Script> scr = cptr[i]->get_script_instance()->get_script(); + while (scr.is_valid()) { + if ((ScriptServer::is_global_class(p_type) && ScriptServer::get_global_class_path(p_type) == scr->get_path()) || p_type == scr->get_path()) { + ret.append(cptr[i]); + break; + } - if (cptr[i]->is_class(p_type)) { - ret.append(cptr[i]); - } else if (cptr[i]->get_script_instance()) { - Ref<Script> scr = cptr[i]->get_script_instance()->get_script(); - while (scr.is_valid()) { - if ((ScriptServer::is_global_class(p_type) && ScriptServer::get_global_class_path(p_type) == scr->get_path()) || p_type == scr->get_path()) { - ret.append(cptr[i]); - break; + scr = scr->get_base_script(); } - - scr = scr->get_base_script(); } } |