From f37c2b5be2b0388fa8871926046955d282391a74 Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Sat, 17 Dec 2022 22:20:27 +0100 Subject: [PATCH] Fix ImageTextureLayered serialisation issues. --- core/io/resource_format_binary.cpp | 11 +++++++---- core/io/resource_format_binary.h | 2 +- scene/resources/image_texture.cpp | 2 +- scene/resources/resource_format_text.cpp | 11 +++++++---- scene/resources/resource_format_text.h | 2 +- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index adae468d931c..551d3268b8ce 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1970,14 +1970,17 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant if (E.usage & PROPERTY_USAGE_STORAGE) { Variant value = res->get(E.name); if (E.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + NonPersistentKey npk; + npk.base = res; + npk.property = E.name; + non_persistent_map[npk] = value; + Ref sres = value; if (sres.is_valid()) { - NonPersistentKey npk; - npk.base = res; - npk.property = E.name; - non_persistent_map[npk] = sres; resource_set.insert(sres); saved_resources.push_back(sres); + } else { + _find_resources(value); } } else { _find_resources(value); diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 30f16649838c..e64485d40439 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -139,7 +139,7 @@ class ResourceFormatSaverBinaryInstance { bool operator<(const NonPersistentKey &p_key) const { return base == p_key.base ? property < p_key.property : base < p_key.base; } }; - RBMap> non_persistent_map; + RBMap non_persistent_map; HashMap string_map; Vector strings; diff --git a/scene/resources/image_texture.cpp b/scene/resources/image_texture.cpp index 4ec81dce657f..922e90f1ba59 100644 --- a/scene/resources/image_texture.cpp +++ b/scene/resources/image_texture.cpp @@ -371,7 +371,7 @@ void ImageTextureLayered::_bind_methods() { ClassDB::bind_method(D_METHOD("_get_images"), &ImageTextureLayered::_get_images); ClassDB::bind_method(D_METHOD("_set_images", "images"), &ImageTextureLayered::_set_images); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_images", PROPERTY_HINT_ARRAY_TYPE, "Image", PROPERTY_USAGE_INTERNAL), "_set_images", "_get_images"); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_images", PROPERTY_HINT_ARRAY_TYPE, "Image", PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT), "_set_images", "_get_images"); } ImageTextureLayered::ImageTextureLayered(LayeredType p_layered_type) { diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index c02431efa807..a2c04698e1e4 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1893,14 +1893,17 @@ void ResourceFormatSaverTextInstance::_find_resources(const Variant &p_variant, Variant v = res->get(I->get().name); if (pi.usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + NonPersistentKey npk; + npk.base = res; + npk.property = pi.name; + non_persistent_map[npk] = v; + Ref sres = v; if (sres.is_valid()) { - NonPersistentKey npk; - npk.base = res; - npk.property = pi.name; - non_persistent_map[npk] = sres; resource_set.insert(sres); saved_resources.push_back(sres); + } else { + _find_resources(v); } } else { _find_resources(v); diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h index c35a594f7270..1734ccc98b47 100644 --- a/scene/resources/resource_format_text.h +++ b/scene/resources/resource_format_text.h @@ -171,7 +171,7 @@ class ResourceFormatSaverTextInstance { bool operator<(const NonPersistentKey &p_key) const { return base == p_key.base ? property < p_key.property : base < p_key.base; } }; - RBMap> non_persistent_map; + RBMap non_persistent_map; HashSet> resource_set; List> saved_resources;