summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2021-06-15 09:52:25 -0700
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2021-06-15 09:55:16 -0700
commit3c3d7380e22c6c3c8031f88944a79be750e1c1ae (patch)
tree73a0e7b0456d822336aa5f1aa91297323bedf031
parent0818a466c0a81c7c9793fd8109d25a74f49c00ae (diff)
Fix sub-resource storing the wrong index in cache
The subindex within Resource wasn't synchronized with the path stored in cache when saving a packed scene. It could cause sub-resources to be swapped when loading the same packed scene in the same session. Now the subindex in Resource reflects the sub-resource path in cache, making saving and loading sub-resources consistent. Co-authored-by: latorril <latorril@gmail.com>
-rw-r--r--scene/resources/resource_format_text.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index 2414704a57..a512d05dfb 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -575,6 +575,7 @@ Error ResourceLoaderText::load() {
int_resources[id] = res; //always assign int resources
if (do_assign && cache_mode != ResourceFormatLoader::CACHE_MODE_IGNORE) {
res->set_path(path, cache_mode == ResourceFormatLoader::CACHE_MODE_REPLACE);
+ res->set_subindex(id);
}
if (progress && resources_total > 0) {