Fix crash when creating C# object for native object at the same time on multiple threads

This commit is contained in:
Wojtek Figat
2021-12-16 18:58:14 +01:00
parent 3c3f2ae075
commit 1c34c7f293
4 changed files with 61 additions and 34 deletions

View File

@@ -175,13 +175,16 @@ void Asset::OnDeleteObject()
#endif
}
void Asset::CreateManaged()
bool Asset::CreateManaged()
{
// Base
ManagedScriptingObject::CreateManaged();
if (ManagedScriptingObject::CreateManaged())
return true;
// Managed objects holds a reference to this asset until it will be removed by GC
AddReference();
return false;
}
void Asset::DestroyManaged()