@@ -19,13 +19,17 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
1919
2020 FScopePythonGIL gil;
2121
22+ #if ENGINE_MINOR_VERSION <= 18
23+ UObject *Context = Stack.Object ;
24+ #endif
25+
2226 UPythonFunction *function = static_cast <UPythonFunction *>(Stack.CurrentNativeFunction );
2327
2428 bool on_error = false ;
2529 bool is_static = function->HasAnyFunctionFlags (FUNC_Static);
2630
2731 // count the number of arguments
28- Py_ssize_t argn = (Stack. Object && !is_static) ? 1 : 0 ;
32+ Py_ssize_t argn = (Context && !is_static) ? 1 : 0 ;
2933 TFieldIterator<UProperty> IArgs (function);
3034 for (; IArgs && ((IArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++IArgs) {
3135 argn++;
@@ -34,22 +38,22 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
3438 UE_LOG (LogPython, Warning, TEXT (" Initializing %d parameters" ), argn);
3539#endif
3640 PyObject *py_args = PyTuple_New (argn);
41+ argn = 0 ;
3742
38- if (Stack. Object && !is_static) {
39- PyObject *py_obj = (PyObject *)ue_get_python_uobject (Stack. Object );
43+ if (Context && !is_static) {
44+ PyObject *py_obj = (PyObject *)ue_get_python_uobject (Context );
4045 if (!py_obj) {
4146 unreal_engine_py_log_error ();
4247 on_error = true ;
4348 }
4449 else {
4550 Py_INCREF (py_obj);
46- PyTuple_SetItem (py_args, 0 , py_obj);
51+ PyTuple_SetItem (py_args, argn++ , py_obj);
4752 }
4853 }
4954
5055 uint8 *frame = Stack.Locals ;
5156
52- argn = (Stack.Object && !is_static) ? 1 : 0 ;
5357 // is it a blueprint call ?
5458 if (*Stack.Code == EX_EndFunctionParms) {
5559 for (UProperty *prop = (UProperty *)function->Children ; prop; prop = (UProperty *)prop->Next ) {
@@ -127,4 +131,4 @@ UPythonFunction::~UPythonFunction()
127131#if defined(UEPY_MEMORY_DEBUG)
128132 UE_LOG (LogPython, Warning, TEXT (" PythonFunction callable %p XDECREF'ed" ), this );
129133#endif
130- }
134+ }
0 commit comments