From 3c3d7380e22c6c3c8031f88944a79be750e1c1ae Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Tue, 15 Jun 2021 09:52:25 -0700 Subject: [PATCH] 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 --- scene/resources/resource_format_text.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 2414704a57a..a512d05dfb6 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) {