Merge pull request #57738 from raulsntos/fix-57503

Attach mono thread before getting `nativeName` field
This commit is contained in:
Ignacio Roldán Etcheverry 2022-02-07 04:58:16 +01:00 committed by GitHub
commit 481b05fef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -3245,6 +3245,8 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
CRASH_COND(!valid); CRASH_COND(!valid);
#endif #endif
GD_MONO_SCOPE_THREAD_ATTACH;
if (native) { if (native) {
StringName native_name = NATIVE_GDMONOCLASS_NAME(native); StringName native_name = NATIVE_GDMONOCLASS_NAME(native);
if (!ClassDB::is_parent_class(p_this->get_class_name(), native_name)) { 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; Callable::CallError unchecked_error;
return _create_instance(nullptr, 0, p_this, Object::cast_to<RefCounted>(p_this) != nullptr, unchecked_error); return _create_instance(nullptr, 0, p_this, Object::cast_to<RefCounted>(p_this) != nullptr, unchecked_error);
} }