diff options
author | Matthew A. Robinson <omegachysis@outlook.com> | 2021-03-23 09:37:27 -0400 |
---|---|---|
committer | Matthew A. Robinson <omegachysis@outlook.com> | 2021-03-23 09:37:27 -0400 |
commit | be4671534caa1e91c42a29732c15572879cac047 (patch) | |
tree | a0db8f38d7ce3f85611707ba934ddf9f1cf9d84b /modules/mono/mono_gd | |
parent | cd05653e308c2263e23debd45211c48af134040d (diff) |
Add mutex to protect script bindings
Diffstat (limited to 'modules/mono/mono_gd')
-rw-r--r-- | modules/mono/mono_gd/gd_mono_internals.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp index fa93c6533a..4ae6af121f 100644 --- a/modules/mono/mono_gd/gd_mono_internals.cpp +++ b/modules/mono/mono_gd/gd_mono_internals.cpp @@ -91,7 +91,11 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) { // The object was just created, no script instance binding should have been attached CRASH_COND(unmanaged->has_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index())); - void *data = (void *)CSharpLanguage::get_singleton()->insert_script_binding(unmanaged, script_binding); + void *data; + { + MutexLock lock(CSharpLanguage::get_singleton()->get_language_bind_mutex()); + data = (void *)CSharpLanguage::get_singleton()->insert_script_binding(unmanaged, script_binding); + } // Should be thread safe because the object was just created and nothing else should be referencing it unmanaged->set_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index(), data); |