Browse Source

Merge pull request #95676 from raulsntos/dotnet/clear-owner-order

C#: Destroy script before clearing owner
Rémi Verschelde 1 year ago
parent
commit
1ac1d03857
1 changed files with 1 additions and 1 deletions
  1. 1 1
      modules/mono/csharp_script.cpp

+ 1 - 1
modules/mono/csharp_script.cpp

@@ -2351,8 +2351,8 @@ CSharpInstance *CSharpScript::_create_instance(const Variant **p_args, int p_arg
 	if (!ok) {
 	if (!ok) {
 		// Important to clear this before destroying the script instance here
 		// Important to clear this before destroying the script instance here
 		instance->script = Ref<CSharpScript>();
 		instance->script = Ref<CSharpScript>();
-		instance->owner = nullptr;
 		p_owner->set_script_instance(nullptr);
 		p_owner->set_script_instance(nullptr);
+		instance->owner = nullptr;
 
 
 		return nullptr;
 		return nullptr;
 	}
 	}