diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 1cff2181af5..54cadf7df34 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2390,7 +2390,7 @@ Ref ResourceFormatLoaderGDScript::load(const String &p_path, const Str } Error err; - Ref script = GDScriptCache::get_full_script(p_path, err); + Ref script = GDScriptCache::get_full_script(p_path, err, "", p_cache_mode == CACHE_MODE_IGNORE); // TODO: Reintroduce binary and encrypted scripts. diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index c25f5b58d52..271296c2f96 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -183,20 +183,26 @@ Ref GDScriptCache::get_shallow_script(const String &p_path, const Stri return script; } -Ref GDScriptCache::get_full_script(const String &p_path, Error &r_error, const String &p_owner) { +Ref 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 script; r_error = OK; if (singleton->full_gdscript_cache.has(p_path)) { - return singleton->full_gdscript_cache[p_path]; + script = Ref(singleton->full_gdscript_cache[p_path]); + if (!p_update_from_disk) { + return script; + } } - Ref script = get_shallow_script(p_path); - ERR_FAIL_COND_V(script.is_null(), Ref()); + if (script.is_null()) { + script = get_shallow_script(p_path); + ERR_FAIL_COND_V(script.is_null(), Ref()); + } r_error = script->load_source_code(p_path); diff --git a/modules/gdscript/gdscript_cache.h b/modules/gdscript/gdscript_cache.h index b971bdd9843..3d111ea2290 100644 --- a/modules/gdscript/gdscript_cache.h +++ b/modules/gdscript/gdscript_cache.h @@ -88,7 +88,7 @@ public: static Ref get_parser(const String &p_path, GDScriptParserRef::Status status, Error &r_error, const String &p_owner = String()); static String get_source_code(const String &p_path); static Ref get_shallow_script(const String &p_path, const String &p_owner = String()); - static Ref get_full_script(const String &p_path, Error &r_error, const String &p_owner = String()); + static Ref get_full_script(const String &p_path, Error &r_error, const String &p_owner = String(), bool p_update_from_disk = false); static Error finish_compiling(const String &p_owner); GDScriptCache();