summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2023-10-31 20:52:27 +0100
committerGitHub <noreply@github.com>2023-10-31 20:52:27 +0100
commit6afd320984cf14198368cc6c53752813a02169e3 (patch)
treec05ba8cf64d7517ac738beec8f5bf1fae55b9800
parent8fc215893af3ea54a8fbd001caee0ce968d206d9 (diff)
parentd515fcc47afe2f1647120ef974b35cb56ff7bfc5 (diff)
downloadredot-engine-6afd320984cf14198368cc6c53752813a02169e3.tar.gz
Merge pull request #78157 from RedworkDE/net-shutting-down-abruptly
C#: Fix crash with `DisposablesTracker_OnGodotShuttingDown`
-rw-r--r--modules/mono/csharp_script.cpp4
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp6
2 files changed, 4 insertions, 6 deletions
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 44bcd4cfe4..3cc32bff10 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -142,6 +142,10 @@ void CSharpLanguage::finalize() {
return;
}
+ if (gdmono && gdmono->is_runtime_initialized() && GDMonoCache::godot_api_cache_updated) {
+ GDMonoCache::managed_callbacks.DisposablesTracker_OnGodotShuttingDown();
+ }
+
finalizing = true;
// Make sure all script binding gchandles are released before finalizing GDMono
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index ca2ad315a7..3eb746677d 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -556,12 +556,6 @@ GDMono::GDMono() {
GDMono::~GDMono() {
finalizing_scripts_domain = true;
- if (is_runtime_initialized()) {
- if (GDMonoCache::godot_api_cache_updated) {
- GDMonoCache::managed_callbacks.DisposablesTracker_OnGodotShuttingDown();
- }
- }
-
if (hostfxr_dll_handle) {
OS::get_singleton()->close_dynamic_library(hostfxr_dll_handle);
}