Merge pull request #56622 from Pineapple/scenestate-optimizations

This commit is contained in:
Rémi Verschelde 2022-01-18 16:35:32 +01:00 committed by GitHub
commit 45cb12955f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -175,14 +175,12 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
#endif
}
} else {
Object *obj = nullptr;
//node belongs to this scene and must be created
Object *obj = ClassDB::instantiate(snames[n.type]);
if (ClassDB::is_class_enabled(snames[n.type])) {
//node belongs to this scene and must be created
obj = ClassDB::instantiate(snames[n.type]);
}
node = Object::cast_to<Node>(obj);
if (!Object::cast_to<Node>(obj)) {
if (!node) {
if (obj) {
memdelete(obj);
obj = nullptr;
@ -203,9 +201,9 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
if (!obj) {
obj = memnew(Node);
}
}
node = Object::cast_to<Node>(obj);
node = Object::cast_to<Node>(obj);
}
}
if (node) {