From f05e3712d66ac96ac8d1a5f287dae71ca4f3f17d Mon Sep 17 00:00:00 2001 From: RedworkDE <10944644+RedworkDE@users.noreply.github.com> Date: Thu, 29 Jun 2023 16:03:22 +0200 Subject: [PATCH] C#: Synchronize adding ScriptInstances (cherry picked from commit 8fdebb85ef180c1e31e023c6b1a51cea683270a1) --- modules/mono/csharp_script.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index a77b1d83adc..e516baedbce 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -1532,7 +1532,10 @@ CSharpInstance *CSharpInstance::create_for_managed_type(Object *p_owner, CSharpS instance->_reference_owner_unsafe(); } - p_script->instances.insert(p_owner); + { + MutexLock lock(CSharpLanguage::get_singleton()->get_script_instances_mutex()); + p_script->instances.insert(p_owner); + } return instance; }