From ae68ee4940497f8730c8dc0405f0910dc57840b1 Mon Sep 17 00:00:00 2001 From: HolonProduction Date: Wed, 7 Jan 2026 18:16:26 +0100 Subject: [PATCH] GDScript: Cache invalid scripts --- modules/gdscript/gdscript_cache.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index 3daa65e0b2..2ad4db7896 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -369,26 +369,26 @@ Ref GDScriptCache::get_full_script(const String &p_path, Error &r_erro Vector buffer = get_binary_tokens(remapped_path); if (buffer.is_empty()) { r_error = ERR_FILE_CANT_READ; - return script; + goto finish; } script->set_binary_tokens_source(buffer); } else { r_error = script->load_source_code(remapped_path); if (r_error) { - return script; + goto finish; } } } // Allowing lifting the lock might cause a script to be reloaded multiple times, // which, as a last resort deadlock prevention strategy, is a good tradeoff. - uint32_t allowance_id = WorkerThreadPool::thread_enter_unlock_allowance_zone(singleton->mutex); - r_error = script->reload(true); - WorkerThreadPool::thread_exit_unlock_allowance_zone(allowance_id); - if (r_error) { - return script; + { + uint32_t allowance_id = WorkerThreadPool::thread_enter_unlock_allowance_zone(singleton->mutex); + r_error = script->reload(true); + WorkerThreadPool::thread_exit_unlock_allowance_zone(allowance_id); } +finish: singleton->full_gdscript_cache[p_path] = script; singleton->shallow_gdscript_cache.erase(p_path);