From dfdb7bdc8798b594aae2062138cd0a3ec3b2df9e Mon Sep 17 00:00:00 2001 From: Ignacio Etcheverry Date: Thu, 23 Apr 2020 02:23:25 +0200 Subject: [PATCH] Mono/C#: Fix assemblies being reloaded a second time unnecesarily (cherry picked from commit c9882e61e2ccc248ee3728ea936bb42e9d145528) --- modules/mono/mono_gd/gd_mono.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index d6d3353a8b5..5c86f9a12bc 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -1386,7 +1386,10 @@ bool _GodotSharp::is_runtime_initialized() { void _GodotSharp::_reload_assemblies(bool p_soft_reload) { #ifdef GD_MONO_HOT_RELOAD - CSharpLanguage::get_singleton()->reload_assemblies(p_soft_reload); + // This method may be called more than once with `call_deferred`, so we need to check + // again if reloading is needed to avoid reloading multiple times unnecessarily. + if (CSharpLanguage::get_singleton()->is_assembly_reloading_needed()) + CSharpLanguage::get_singleton()->reload_assemblies(p_soft_reload); #endif }