diff options
author | George Marques <george@gmarqu.es> | 2020-08-18 10:36:01 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2020-08-18 11:21:09 -0300 |
commit | 8088e9e6acb3d8cec00610e9345596bbabed6923 (patch) | |
tree | d028b6343f62e4174806c1182007366a27ef4af1 /modules | |
parent | 0f9923e67f477ebab1fe903de53bf117ec3a886f (diff) |
GDScript: Add script to cache on reload
This ensures that scripts created without a resource loader are properly
included in the cache (such as builtin scripts) and are not tried to be
loaded from the disk.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 9170255c02..541d46a2af 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -596,6 +596,21 @@ Error GDScript::reload(bool p_keep_state) { return OK; } + { + String source_path = path; + if (source_path.empty()) { + source_path = get_path(); + } + if (!source_path.empty()) { + MutexLock lock(GDScriptCache::singleton->lock); + Ref<GDScript> self(this); + if (!GDScriptCache::singleton->shallow_gdscript_cache.has(source_path)) { + GDScriptCache::singleton->shallow_gdscript_cache[source_path] = self; + self->unreference(); + } + } + } + valid = false; GDScriptParser parser; Error err = parser.parse(source, path, false); |