Merge pull request #52775 from gyroninja/fix-instantiated-root-node-crash

Fail at instantiating a packed scene if the root node is instantiated
This commit is contained in:
Rémi Verschelde 2021-09-21 14:23:54 +02:00 committed by GitHub
commit dc2b062609
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -99,8 +99,9 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
#endif
parent = nparent;
} else {
// i == 0 is root node. Confirm that it doesn't have a parent defined.
// i == 0 is root node.
ERR_FAIL_COND_V_MSG(n.parent != -1, nullptr, vformat("Invalid scene: root node %s cannot specify a parent node.", snames[n.name]));
ERR_FAIL_COND_V_MSG(n.type == TYPE_INSTANCED && base_scene_idx < 0, nullptr, vformat("Invalid scene: root node %s in an instance, but there's no base scene.", snames[n.name]));
}
Node *node = nullptr;