summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2024-02-22 12:53:19 +0100
committerPedro J. Estébanez <pedrojrulez@gmail.com>2024-02-26 14:59:04 +0100
commit5e144022e70975a246a14f0343215cde92893b7b (patch)
treec0600708b1c97e924e8e99384f2f67384b6e09f8 /modules
parentbb6b06c81343073f10cbbd2af515cf0dac1e6549 (diff)
downloadredot-engine-5e144022e70975a246a14f0343215cde92893b7b.tar.gz
Enhance cache modes in resource loading
- Unify documentation, hoping to clear misconcepctions about about propagation of the cache mode across dependant loads. - Clarify in docs that `CACHE_MODE_REPLACE` now also works on the main resource (from #87008). - Add two recursive modes, counterparts of `CACHE_MODE_REPLACE` and `CACHE_MODE_IGNORE`, since it seems some need them (see #59669, #82830). - Let resources, even loaded with one of the ignore-cache modes, get a path, which is useful for tools.
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gdscript.cpp3
-rw-r--r--modules/mono/csharp_script.cpp2
2 files changed, 4 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp
index 2d6c0c1d11..70f4411dec 100644
--- a/modules/gdscript/gdscript.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -2817,7 +2817,8 @@ Ref<GDScript> GDScriptLanguage::get_script_by_fully_qualified_name(const String
Ref<Resource> ResourceFormatLoaderGDScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
Error err;
- Ref<GDScript> scr = GDScriptCache::get_full_script(p_path, err, "", p_cache_mode == CACHE_MODE_IGNORE);
+ bool ignoring = p_cache_mode == CACHE_MODE_IGNORE || p_cache_mode == CACHE_MODE_IGNORE_DEEP;
+ Ref<GDScript> scr = GDScriptCache::get_full_script(p_path, err, "", ignoring);
if (err && scr.is_valid()) {
// If !scr.is_valid(), the error was likely from scr->load_source_code(), which already generates an error.
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 88fe82c6b8..9ccaa27e84 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -2854,6 +2854,7 @@ Ref<Resource> ResourceFormatLoaderCSharpScript::load(const String &p_path, const
Ref<Resource> existing = ResourceCache::get_ref(p_path);
switch (p_cache_mode) {
case ResourceFormatLoader::CACHE_MODE_IGNORE:
+ case ResourceFormatLoader::CACHE_MODE_IGNORE_DEEP:
break;
case ResourceFormatLoader::CACHE_MODE_REUSE:
if (existing.is_null()) {
@@ -2863,6 +2864,7 @@ Ref<Resource> ResourceFormatLoaderCSharpScript::load(const String &p_path, const
}
break;
case ResourceFormatLoader::CACHE_MODE_REPLACE:
+ case ResourceFormatLoader::CACHE_MODE_REPLACE_DEEP:
scr->set_path(p_original_path, true);
break;
}