diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2022-12-10 19:31:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-10 19:31:57 +0100 |
commit | 561bafe91fff234a611365d41f03df680349ac46 (patch) | |
tree | dbdb49f38e1a59f71124dab2500e42f507325a1a /modules/gdscript/gdscript_cache.cpp | |
parent | e9c7140cfa6fa6e839730d4f43377dc7237b8ba4 (diff) | |
parent | ff544df926d90724f2dbb6ef53667a1ee2ecdbb5 (diff) | |
download | redot-engine-561bafe91fff234a611365d41f03df680349ac46.tar.gz |
Merge pull request #69865 from adamscott/fix-gdscript-cache-remove-script-crash
Fix `GDScriptCache` to not remove scripts/scenes individually when clearing
Diffstat (limited to 'modules/gdscript/gdscript_cache.cpp')
-rw-r--r-- | modules/gdscript/gdscript_cache.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index 1df7757082..1dc5e335a0 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -128,6 +128,10 @@ void GDScriptCache::move_script(const String &p_from, const String &p_to) { MutexLock lock(singleton->mutex); + if (singleton->cleared) { + return; + } + for (KeyValue<String, HashSet<String>> &E : singleton->packed_scene_dependencies) { if (E.value.has(p_from)) { E.value.insert(p_to); @@ -158,6 +162,10 @@ void GDScriptCache::remove_script(const String &p_path) { MutexLock lock(singleton->mutex); + if (singleton->cleared) { + return; + } + for (KeyValue<String, HashSet<String>> &E : singleton->packed_scene_dependencies) { if (!E.value.has(p_path)) { continue; @@ -371,6 +379,10 @@ void GDScriptCache::clear_unreferenced_packed_scenes() { MutexLock lock(singleton->mutex); + if (singleton->cleared) { + return; + } + for (KeyValue<String, HashSet<String>> &E : singleton->packed_scene_dependencies) { if (E.value.size() > 0 || !ResourceLoader::is_imported(E.key)) { continue; @@ -388,6 +400,11 @@ void GDScriptCache::clear() { MutexLock lock(singleton->mutex); + if (singleton->cleared) { + return; + } + singleton->cleared = true; + RBSet<Ref<GDScriptParserRef>> parser_map_refs; for (KeyValue<String, GDScriptParserRef *> &E : singleton->parser_map) { parser_map_refs.insert(E.value); @@ -417,7 +434,8 @@ GDScriptCache::GDScriptCache() { } GDScriptCache::~GDScriptCache() { - destructing = true; - clear(); + if (!cleared) { + clear(); + } singleton = nullptr; } |