From e99cf6bfe5ac659de503040c3da9a90b135d7619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Wed, 18 Nov 2020 23:45:30 +0100 Subject: [PATCH] Fix crash duplicating local-to-scene resources --- core/io/resource.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 08f50218891..58ab9a8cde4 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -147,8 +147,8 @@ Ref Resource::duplicate_for_local_scene(Node *p_for_scene, Map plist; get_property_list(&plist); - Resource *r = Object::cast_to(ClassDB::instance(get_class())); - ERR_FAIL_COND_V(!r, Ref()); + Ref r = Object::cast_to(ClassDB::instance(get_class())); + ERR_FAIL_COND_V(r.is_null(), Ref()); r->local_scene = p_for_scene; @@ -175,9 +175,7 @@ Ref Resource::duplicate_for_local_scene(Node *p_for_scene, Mapset(E->get().name, p); } - RES res = Ref(r); - - return res; + return r; } void Resource::configure_for_local_scene(Node *p_for_scene, Map, Ref> &remap_cache) {