diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-25 11:28:45 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-09-25 11:28:45 +0200 |
commit | 15ac442247b2b45ae0e2900d18f26e5b82e6c011 (patch) | |
tree | f5a27975551d09144b9cd87e0fc68678f65e5094 /modules/gdscript/gdscript_cache.cpp | |
parent | fd62fbcf8c1a20231d995e157aeaad92a5a03824 (diff) | |
parent | f1a4041f52134bd6c5ff7cb41529031c0afc5338 (diff) | |
download | redot-engine-15ac442247b2b45ae0e2900d18f26e5b82e6c011.tar.gz |
Merge pull request #63224 from Rindbee/update-GDScript-cache
Load/update GDScript from disk on load if cache mode is CACHE_MODE_IGNORE
Diffstat (limited to 'modules/gdscript/gdscript_cache.cpp')
-rw-r--r-- | modules/gdscript/gdscript_cache.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index c25f5b58d5..271296c2f9 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -183,20 +183,26 @@ Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, const Stri return script; } -Ref<GDScript> GDScriptCache::get_full_script(const String &p_path, Error &r_error, const String &p_owner) { +Ref<GDScript> GDScriptCache::get_full_script(const String &p_path, Error &r_error, const String &p_owner, bool p_update_from_disk) { MutexLock lock(singleton->lock); if (!p_owner.is_empty()) { singleton->dependencies[p_owner].insert(p_path); } + Ref<GDScript> script; r_error = OK; if (singleton->full_gdscript_cache.has(p_path)) { - return singleton->full_gdscript_cache[p_path]; + script = Ref<GDScript>(singleton->full_gdscript_cache[p_path]); + if (!p_update_from_disk) { + return script; + } } - Ref<GDScript> script = get_shallow_script(p_path); - ERR_FAIL_COND_V(script.is_null(), Ref<GDScript>()); + if (script.is_null()) { + script = get_shallow_script(p_path); + ERR_FAIL_COND_V(script.is_null(), Ref<GDScript>()); + } r_error = script->load_source_code(p_path); |