From d515fcc47afe2f1647120ef974b35cb56ff7bfc5 Mon Sep 17 00:00:00 2001 From: RedworkDE <10944644+RedworkDE@users.noreply.github.com> Date: Mon, 12 Jun 2023 21:59:48 +0200 Subject: [PATCH] C#: Fix crash with `DisposablesTracker_OnGodotShuttingDown` --- modules/mono/csharp_script.cpp | 4 ++++ modules/mono/mono_gd/gd_mono.cpp | 6 ------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 05595e7e452..e06440230b2 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -139,6 +139,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 97bf49271af..675a8c13373 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -534,12 +534,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); }