Add crash to soft-return if managed event bind target object native instance is gone

#1278
This commit is contained in:
Wojtek Figat
2023-08-14 18:40:03 +02:00
parent b3a359b158
commit 1948a84301

View File

@@ -1116,7 +1116,7 @@ namespace Flax.Build.Bindings
var signatureEnd = contents.Length;
if (useSeparateImpl)
{
// Write declarion only, function definition wil be put in the end of the file
// Write declaration only, function definition wil be put in the end of the file
CppContentsEnd.AppendFormat("{0} {2}::{1}(", returnValueType, functionInfo.UniqueName, callerName);
CppContentsEnd.Append(contents.ToString(signatureStart, signatureEnd - signatureStart));
contents.Append(';').AppendLine();
@@ -2016,7 +2016,7 @@ namespace Flax.Build.Bindings
var indent = " ";
if (useSeparateImpl)
{
// Write declarion only, function definition wil be put in the end of the file
// Write declaration only, function definition wil be put in the end of the file
CppContentsEnd.AppendFormat("void {1}::{0}_ManagedBind(", eventInfo.Name, internalTypeName);
var sig = contents.ToString(signatureStart, contents.Length - signatureStart);
CppContentsEnd.Append(contents.ToString(signatureStart, contents.Length - signatureStart));
@@ -2027,6 +2027,8 @@ namespace Flax.Build.Bindings
contents.AppendLine().Append(indent).Append('{').AppendLine();
if (buildData.Toolchain?.Compiler == TargetCompiler.MSVC)
contents.Append(indent).AppendLine($" MSVC_FUNC_EXPORT(\"{classTypeNameManaged}::Internal_{eventInfo.Name}_Bind\")"); // Export generated function binding under the C# name
if (!eventInfo.IsStatic)
contents.Append(indent).Append(" if (__obj == nullptr) return;").AppendLine();
contents.Append(indent).Append(" Function<void(");
for (var i = 0; i < paramsCount; i++)
{