Merge pull request #43889 from omegachysis/3.2
[3.x] Fix race condition on `script_binding` in C#
This commit is contained in:
commit
6fbe785cff
1 changed files with 5 additions and 1 deletions
|
@ -90,7 +90,11 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) {
|
||||||
// The object was just created, no script instance binding should have been attached
|
// 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()));
|
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
|
// 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);
|
unmanaged->set_script_instance_binding(CSharpLanguage::get_singleton()->get_language_index(), data);
|
||||||
|
|
Loading…
Reference in a new issue