From 303f0c8626aea2aef21a70a1598f689ee4e16b0d Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Mon, 7 Feb 2022 03:41:44 +0100 Subject: Attach mono thread before getting nativeName field In order to access the `nativeName` constant field from a C# class, the mono scope thread must be attached or the mono domain will be null. --- modules/mono/csharp_script.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/mono') diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 26436e3ec0..085ab9a467 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -3245,6 +3245,8 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) { CRASH_COND(!valid); #endif + GD_MONO_SCOPE_THREAD_ATTACH; + if (native) { StringName native_name = NATIVE_GDMONOCLASS_NAME(native); if (!ClassDB::is_parent_class(p_this->get_class_name(), native_name)) { @@ -3257,8 +3259,6 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) { } } - GD_MONO_SCOPE_THREAD_ATTACH; - Callable::CallError unchecked_error; return _create_instance(nullptr, 0, p_this, Object::cast_to(p_this) != nullptr, unchecked_error); } -- cgit v1.2.3