summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBimDav <67792882+BimDav@users.noreply.github.com>2022-05-16 19:40:59 +0200
committerBimDav <67792882+BimDav@users.noreply.github.com>2022-05-16 19:40:59 +0200
commit3e96abce07f88b5e32c619d94a602b81bd8c27c0 (patch)
tree361c74dd2ee2e63fafcb63bdfb03c9ef82f91904
parent4654de547458cc69a36abf6df65c219469abfa85 (diff)
fix a bug in get_node_and_resource
-rw-r--r--scene/main/node.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 0c1a62c667..bd791dff2a 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2528,9 +2528,10 @@ Node *Node::get_node_and_resource(const NodePath &p_path, Ref<Resource> &r_res,
int j = 0;
// If not p_last_is_property, we shouldn't consider the last one as part of the resource
for (; j < p_path.get_subname_count() - (int)p_last_is_property; j++) {
- Variant new_res_v = j == 0 ? node->get(p_path.get_subname(j)) : r_res->get(p_path.get_subname(j));
+ bool is_valid = false;
+ Variant new_res_v = j == 0 ? node->get(p_path.get_subname(j), &is_valid) : r_res->get(p_path.get_subname(j), &is_valid);
- if (new_res_v.get_type() == Variant::NIL) { // Found nothing on that path
+ if (!is_valid) { // Found nothing on that path
return nullptr;
}