20tab / UnrealEnginePython

Embed Python in Unreal Engine 4
MIT License
2.75k stars 746 forks source link

4.26.2 Python 3.7 Crash When call bind_event in uep #873

Open zhuqhang opened 2 years ago

zhuqhang commented 2 years ago

This is my Crash log [2021.11.20-09.47.42:845][301]LogWindows: Error: [Callstack] 0x00007fff1bf6ac13 UE4Editor-UnrealEnginePython-0001.dll!ue_bind_pyevent() [F:\Ue4Project\UePythonTutorial\UePythonTutorial\Plugins\UnrealEnginePython-20210923\Source\UnrealEnginePython\Private\UEPyModule.cpp:4471] [2021.11.20-09.47.42:845][301]LogWindows: Error: [Callstack] 0x00007fff1bfbb1cf UE4Editor-UnrealEnginePython-0001.dll!py_ue_bind_event() [F:\Ue4Project\UePythonTutorial\UePythonTutorial\Plugins\UnrealEnginePython-20210923\Source\UnrealEnginePython\Private\UObject\UEPyObject.cpp:1760]

debug found this FORCEINLINE TArray(const TArray& Other) { CopyToEmpty(Other.GetData(), Other.Num(), 0, 0); } then crashed ?? How fix it?? Please help me !

F-DR commented 2 years ago

i has the same situation

kprimo commented 2 years ago

try this to fix the problem:

  1. find the cpp file UEPyModule.cpp, replace if (auto casted_prop = Cast<UMulticastDelegateProperty>(u_property)){...} code around line#3064 to these code:

    if (auto casted_prop = Cast<UMulticastDelegateProperty>(f_property))
    {
    FScriptDelegate script_delegate;
    UPythonDelegate* py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewDelegate(u_obj->ue_object, py_callable, casted_prop->SignatureFunction);
    // fake UFUNCTION for bypassing checks
    script_delegate.BindUFunction(py_delegate, FName("PyFakeCallable"));
    
    casted_prop->AddDelegate(script_delegate, u_obj->ue_object);
    }

    refer to https://github.com/20tab/UnrealEnginePython/issues/801#issuecomment-566355487