diff options
author | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2020-11-18 23:45:30 +0100 |
---|---|---|
committer | Pedro J. Estébanez <pedrojrulez@gmail.com> | 2020-11-18 23:45:30 +0100 |
commit | e99cf6bfe5ac659de503040c3da9a90b135d7619 (patch) | |
tree | 465ea38e75af9420b14deea8bded4841a14523e1 /core | |
parent | a3a3b02bed3137e0ccac2cbb544a71502a659b80 (diff) |
Fix crash duplicating local-to-scene resources
Diffstat (limited to 'core')
-rw-r--r-- | core/io/resource.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 08f5021889..58ab9a8cde 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -147,8 +147,8 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res List<PropertyInfo> plist; get_property_list(&plist); - Resource *r = Object::cast_to<Resource>(ClassDB::instance(get_class())); - ERR_FAIL_COND_V(!r, Ref<Resource>()); + Ref<Resource> r = Object::cast_to<Resource>(ClassDB::instance(get_class())); + ERR_FAIL_COND_V(r.is_null(), Ref<Resource>()); r->local_scene = p_for_scene; @@ -175,9 +175,7 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res r->set(E->get().name, p); } - RES res = Ref<Resource>(r); - - return res; + return r; } void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource>> &remap_cache) { |