diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-06 16:11:21 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2022-12-06 16:11:21 +0100 |
commit | 9bd7ad53f7d8b53bb2fa5185f782b6369e38c24a (patch) | |
tree | cf9a049ed4a72377f096c80681b047be5e7fd1b6 /modules/gdscript/gdscript_cache.cpp | |
parent | 6717c4cad2a670fda588d11a27132452a1301ad6 (diff) | |
parent | 88f3045301470fd13bbe3ade6537a1c1cb1227fe (diff) | |
download | redot-engine-9bd7ad53f7d8b53bb2fa5185f782b6369e38c24a.tar.gz |
Merge pull request #69506 from adamscott/move-gdscript-uninit-to-finalize
Move GDScript uninitialization to `GDScriptLanguage::finish()`
Diffstat (limited to 'modules/gdscript/gdscript_cache.cpp')
-rw-r--r-- | modules/gdscript/gdscript_cache.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/modules/gdscript/gdscript_cache.cpp b/modules/gdscript/gdscript_cache.cpp index 021504f242..699ce67933 100644 --- a/modules/gdscript/gdscript_cache.cpp +++ b/modules/gdscript/gdscript_cache.cpp @@ -381,15 +381,15 @@ void GDScriptCache::clear_unreferenced_packed_scenes() { } } -GDScriptCache::GDScriptCache() { - singleton = this; -} +void GDScriptCache::clear() { + if (singleton == nullptr) { + return; + } -GDScriptCache::~GDScriptCache() { - destructing = true; + MutexLock lock(singleton->mutex); RBSet<Ref<GDScriptParserRef>> parser_map_refs; - for (KeyValue<String, GDScriptParserRef *> &E : parser_map) { + for (KeyValue<String, GDScriptParserRef *> &E : singleton->parser_map) { parser_map_refs.insert(E.value); } @@ -399,12 +399,20 @@ GDScriptCache::~GDScriptCache() { } parser_map_refs.clear(); - parser_map.clear(); - shallow_gdscript_cache.clear(); - full_gdscript_cache.clear(); + singleton->parser_map.clear(); + singleton->shallow_gdscript_cache.clear(); + singleton->full_gdscript_cache.clear(); - packed_scene_cache.clear(); - packed_scene_dependencies.clear(); + singleton->packed_scene_cache.clear(); + singleton->packed_scene_dependencies.clear(); +} + +GDScriptCache::GDScriptCache() { + singleton = this; +} +GDScriptCache::~GDScriptCache() { + destructing = true; + clear(); singleton = nullptr; } |