Skip to content

Commit

Permalink
Merge pull request #67612 from timothyqiu/who-ami-i-3.x
Browse files Browse the repository at this point in the history
[3.x] Fix get_path() error when calling get_node()
  • Loading branch information
akien-mga committed Oct 31, 2022
2 parents 64635af + 5d6dc20 commit 80b50e5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,12 +1466,23 @@ Node *Node::get_node_or_null(const NodePath &p_path) const {
Node *Node::get_node(const NodePath &p_path) const {
Node *node = get_node_or_null(p_path);
if (unlikely(!node)) {
// Try to get a clear description of this node in the error message.
String desc;
if (is_inside_tree()) {
desc = get_path();
} else {
desc = get_name();
if (desc.empty()) {
desc = get_class();
}
}

if (p_path.is_absolute()) {
ERR_FAIL_V_MSG(nullptr,
vformat("(Node not found: \"%s\" (absolute path attempted from \"%s\").)", p_path, get_path()));
vformat("(Node not found: \"%s\" (absolute path attempted from \"%s\").)", p_path, desc));
} else {
ERR_FAIL_V_MSG(nullptr,
vformat("(Node not found: \"%s\" (relative to \"%s\").)", p_path, get_path()));
vformat("(Node not found: \"%s\" (relative to \"%s\").)", p_path, desc));
}
}

Expand Down

0 comments on commit 80b50e5

Please sign in to comment.