Skip to content

Commit 9923179

Browse files
authored
Merge pull request #60893 from KoBeWi/node_rescue
2 parents a7c69bd + 2b53826 commit 9923179

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

scene/resources/packed_scene.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,16 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
112112
const NodeData &n = nd[i];
113113

114114
Node *parent = nullptr;
115+
String old_parent_path;
115116

116117
if (i > 0) {
117118
ERR_FAIL_COND_V_MSG(n.parent == -1, nullptr, vformat("Invalid scene: node %s does not specify its parent node.", snames[n.name]));
118119
NODE_FROM_ID(nparent, n.parent);
119120
#ifdef DEBUG_ENABLED
120121
if (!nparent && (n.parent & FLAG_ID_IS_PATH)) {
121122
WARN_PRINT(String("Parent path '" + String(node_paths[n.parent & FLAG_MASK]) + "' for node '" + String(snames[n.name]) + "' has vanished when instancing: '" + get_path() + "'.").ascii().get_data());
123+
old_parent_path = String(node_paths[n.parent & FLAG_MASK]).trim_prefix("./").replace("/", "@");
124+
nparent = ret_nodes[0];
122125
}
123126
#endif
124127
parent = nparent;
@@ -332,6 +335,10 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
332335
}
333336
}
334337

338+
if (!old_parent_path.is_empty()) {
339+
node->_set_name_nocheck(old_parent_path + "@" + node->get_name());
340+
}
341+
335342
if (n.owner >= 0) {
336343
NODE_FROM_ID(owner, n.owner);
337344
if (owner) {

0 commit comments

Comments
 (0)