diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-19 22:33:46 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-19 22:33:46 +0200 |
commit | cce100a84058999ad28007efe36bac32896e8cc9 (patch) | |
tree | 5aac00dd27036603ec3b8c59b4f7b10005d25e4c /scene/main/node.cpp | |
parent | 080d471e9812323b177492ec90fad34c3da38869 (diff) | |
parent | d159123633beb756c923d1dbb3faee6657269b2c (diff) | |
download | redot-engine-cce100a84058999ad28007efe36bac32896e8cc9.tar.gz |
Merge pull request #75459 from kleonc/node-fix-find-children
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 ea89a719e8..a21866610c 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1665,25 +1665,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(); } } |