diff options
author | Juan Linietsky <juan@godotengine.org> | 2019-02-21 20:49:42 -0300 |
---|---|---|
committer | Juan Linietsky <juan@godotengine.org> | 2019-02-21 20:49:42 -0300 |
commit | 8b231b96e347b677ea4189784c960bc4517b8e6a (patch) | |
tree | b5bf271cdce01341e4b221badcdc2c67bbef24f3 /core/io/resource_format_binary.cpp | |
parent | 5784caae73dbb9dcb1e6640884782859c5ab94b6 (diff) | |
download | redot-engine-8b231b96e347b677ea4189784c960bc4517b8e6a.tar.gz |
Implement a cleaner (and better) way to save imagedata from ImageTexture, fixes #18801
Diffstat (limited to 'core/io/resource_format_binary.cpp')
-rw-r--r-- | core/io/resource_format_binary.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 77e3efb3a0..d2c656b8eb 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1666,7 +1666,20 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant if (E->get().usage & PROPERTY_USAGE_STORAGE) { - _find_resources(res->get(E->get().name)); + Variant value = res->get(E->get().name); + if (E->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + RES sres = value; + if (sres.is_valid()) { + NonPersistentKey npk; + npk.base = res; + npk.property = E->get().name; + non_persistent_map[npk] = sres; + resource_set.insert(sres); + saved_resources.push_back(sres); + } + } else { + _find_resources(value); + } } } @@ -1810,7 +1823,17 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p if ((F->get().usage & PROPERTY_USAGE_STORAGE)) { Property p; p.name_idx = get_string_index(F->get().name); - p.value = E->get()->get(F->get().name); + + if (F->get().usage & PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT) { + NonPersistentKey npk; + npk.base = E->get(); + npk.property = F->get().name; + if (non_persistent_map.has(npk)) { + p.value = non_persistent_map[npk]; + } + } else { + p.value = E->get()->get(F->get().name); + } Variant default_value = ClassDB::class_get_default_property_value(E->get()->get_class(), F->get().name); |