From 5ed5719440873ef7fdac3efc556836689a2b5097 Mon Sep 17 00:00:00 2001 From: kprimo <1037136268@qq.com> Date: Mon, 21 Mar 2022 22:03:38 +0800 Subject: [PATCH] fix the problem which multiscrpit_delegate causes engine crash. --- .../UnrealEnginePython/Private/UEPyModule.cpp | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Source/UnrealEnginePython/Private/UEPyModule.cpp b/Source/UnrealEnginePython/Private/UEPyModule.cpp index 1c56a47c1..abcf8f96f 100644 --- a/Source/UnrealEnginePython/Private/UEPyModule.cpp +++ b/Source/UnrealEnginePython/Private/UEPyModule.cpp @@ -4460,16 +4460,16 @@ PyObject* ue_bind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* py_ } #if ENGINE_MINOR_VERSION >= 25 - if (auto casted_prop = CastField(f_property)) + if (auto casted_prop = Cast(f_property)) #else if (auto casted_prop = Cast(u_property)) #endif { -#if ENGINE_MINOR_VERSION < 23 - FMulticastScriptDelegate multiscript_delegate = casted_prop->GetPropertyValue_InContainer(u_obj->ue_object); -#else - FMulticastScriptDelegate multiscript_delegate = *casted_prop->GetMulticastDelegate(u_obj->ue_object); -#endif + //#if ENGINE_MINOR_VERSION < 23 + // FMulticastScriptDelegate multiscript_delegate = casted_prop->GetPropertyValue_InContainer(u_obj->ue_object); + //#else + // FMulticastScriptDelegate multiscript_delegate = *casted_prop->GetMulticastDelegate(u_obj->ue_object); + //#endif FScriptDelegate script_delegate; #if ENGINE_MINOR_VERSION >= 25 @@ -4482,14 +4482,15 @@ PyObject* ue_bind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* py_ script_delegate.BindUFunction(py_delegate, FName("PyFakeCallable")); // add the new delegate - multiscript_delegate.Add(script_delegate); + //multiscript_delegate.Add(script_delegate); + casted_prop->AddDelegate(script_delegate, u_obj->ue_object); // re-assign multicast delegate -#if ENGINE_MINOR_VERSION < 23 - casted_prop->SetPropertyValue_InContainer(u_obj->ue_object, multiscript_delegate); -#else - casted_prop->SetMulticastDelegate(u_obj->ue_object, multiscript_delegate); -#endif +//#if ENGINE_MINOR_VERSION < 23 +// casted_prop->SetPropertyValue_InContainer(u_obj->ue_object, multiscript_delegate); +//#else +// casted_prop->SetMulticastDelegate(u_obj->ue_object, multiscript_delegate); +//#endif } #if ENGINE_MINOR_VERSION >= 25 else if (auto casted_prop_delegate = CastField(f_property))