1
0
mirror of https://github.com/godotengine/godot synced 2024-07-08 15:50:44 +00:00

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.
This commit is contained in:
George Marques 2020-08-18 10:36:01 -03:00
parent 0f9923e67f
commit 8088e9e6ac
No known key found for this signature in database
GPG Key ID: 046BD46A3201E43D

View File

@ -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);