This commit is contained in:
Brian Semrau 2021-11-08 15:10:01 -03:00 committed by GitHub
commit 8d1b690d1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 7 deletions

View file

@ -860,6 +860,8 @@ Error GDScript::reload(bool p_keep_state) {
GDScriptCompiler compiler;
err = compiler.compile(&parser, this, p_keep_state);
MutexLock lock(GDScriptLanguage::singleton->lock);
#ifdef TOOLS_ENABLED
_update_doc();
#endif

View file

@ -184,21 +184,28 @@ Ref<GDScript> GDScriptCache::get_shallow_script(const String &p_path, const Stri
}
Ref<GDScript> GDScriptCache::get_full_script(const String &p_path, Error &r_error, const String &p_owner) {
MutexLock lock(singleton->lock);
Ref<GDScript> script;
if (p_owner != String()) {
MutexLock lock(singleton->lock);
singleton->dependencies[p_owner].insert(p_path);
}
r_error = OK;
if (singleton->full_gdscript_cache.has(p_path)) {
return singleton->full_gdscript_cache[p_path];
{
MutexLock lock(singleton->lock);
if (singleton->full_gdscript_cache.has(p_path)) {
return Ref(singleton->full_gdscript_cache[p_path]);
}
}
Ref<GDScript> script = get_shallow_script(p_path);
script = get_shallow_script(p_path);
ERR_FAIL_COND_V(script.is_null(), Ref<GDScript>());
r_error = script->load_source_code(p_path);
{
MutexLock lock(singleton->lock);
r_error = script->load_source_code(p_path);
}
if (r_error) {
return script;
@ -209,8 +216,11 @@ Ref<GDScript> GDScriptCache::get_full_script(const String &p_path, Error &r_erro
return script;
}
singleton->full_gdscript_cache[p_path] = script.ptr();
singleton->shallow_gdscript_cache.erase(p_path);
{
MutexLock lock(singleton->lock);
singleton->full_gdscript_cache[p_path] = script.ptr();
singleton->shallow_gdscript_cache.erase(p_path);
}
return script;
}