summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Rubinsky <chaosus89@gmail.com>2022-08-28 21:56:04 +0300
committerYuri Rubinsky <chaosus89@gmail.com>2022-08-28 21:56:04 +0300
commita33903d23fb65bc84dd19487d0552f2a4670f803 (patch)
tree779cca197f1fa164579f8b3f20cf6ba5383a0d6d
parent006915b4824a91c0e0fc95ac6aa2f70908a0a027 (diff)
Prevent crash at loading some scenes
-rw-r--r--scene/resources/packed_scene.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index dcccc6898b..fc261397c6 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -288,9 +288,11 @@ Node *SceneState::instantiate(GenEditState p_edit_state) const {
// then tell this node to reference that resource.
if (n.instance >= 0) {
Ref<Resource> node_res = node->get(snames[nprops[j].name]);
- node_res->copy_from(res);
- node_res->configure_for_local_scene(node, resources_local_to_scene);
- value = node_res;
+ if (node_res.is_valid()) {
+ node_res->copy_from(res);
+ node_res->configure_for_local_scene(node, resources_local_to_scene);
+ value = node_res;
+ }
} else {
HashMap<Ref<Resource>, Ref<Resource>>::Iterator E = resources_local_to_scene.find(res);
Node *base = i == 0 ? node : ret_nodes[0];