1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

GDScript: invalidate GDScriptParserRef when reloading

This commit is contained in:
rune-scape
2024-04-12 16:13:25 -07:00
parent 029aadef56
commit 6b88c86cec
8 changed files with 139 additions and 106 deletions

View File

@@ -739,10 +739,18 @@ Error GDScript::reload(bool p_keep_state) {
if (source_path.is_empty()) {
source_path = get_path();
}
Ref<GDScript> cached_script = GDScriptCache::get_cached_script(source_path);
if (!source_path.is_empty() && cached_script.is_null()) {
MutexLock lock(GDScriptCache::singleton->mutex);
GDScriptCache::singleton->shallow_gdscript_cache[source_path] = Ref<GDScript>(this);
if (!source_path.is_empty()) {
if (GDScriptCache::get_cached_script(source_path).is_null()) {
MutexLock lock(GDScriptCache::singleton->mutex);
GDScriptCache::singleton->shallow_gdscript_cache[source_path] = Ref<GDScript>(this);
}
if (GDScriptCache::has_parser(source_path)) {
Error err = OK;
Ref<GDScriptParserRef> parser_ref = GDScriptCache::get_parser(source_path, GDScriptParserRef::EMPTY, err);
if (parser_ref.is_valid() && parser_ref->get_source_hash() != source.hash()) {
GDScriptCache::remove_parser(source_path);
}
}
}
}