@@ -26,6 +26,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
2626
2727 bool on_error = false ;
2828 bool is_static = function->HasAnyFunctionFlags (FUNC_Static);
29+ FOutParmRec *OutParms = nullptr ;
2930
3031 // count the number of arguments
3132 Py_ssize_t argn = (Context && !is_static) ? 1 : 0 ;
@@ -73,8 +74,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
7374 }
7475 else
7576 { // blueprint call
76- // largely copied from ScriptCore.cpp::CallFunction - for BP calls, we need to set up the FOutParmRec stuff ourselves
77- Stack.OutParms = NULL ;
77+ // largely copied from ScriptCore.cpp::CallFunction - for BP calls, we need to set up some of the FOutParmRec stuff ourselves
7878 frame = (uint8 *)FMemory_Alloca (function->PropertiesSize );
7979 FMemory::Memzero (frame, function->PropertiesSize );
8080 for (UProperty *prop = (UProperty *)function->Children ; *Stack.Code != EX_EndFunctionParms; prop = (UProperty *)prop->Next )
@@ -85,8 +85,8 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
8585 FOutParmRec *rec = (FOutParmRec*)FMemory_Alloca (sizeof (FOutParmRec));
8686 rec->Property = prop;
8787 rec->PropAddr = Stack.MostRecentPropertyAddress ;
88- rec->NextOutParm = Stack. OutParms ;
89- Stack. OutParms = rec;
88+ rec->NextOutParm = OutParms;
89+ OutParms = rec;
9090 continue ;
9191 }
9292 if (!on_error) {
@@ -148,8 +148,8 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
148148 }
149149 }
150150 else
151- { // Find the given FOutParmRec for this property
152- uint8 *out_frame = frame ;
151+ { // Find the given FOutParmRec for this property - look in the stack first
152+ uint8 *out_frame = nullptr ;
153153 for (FOutParmRec *rec = Stack.OutParms ; rec != nullptr ; rec = rec->NextOutParm )
154154 {
155155 if (rec->Property == prop)
@@ -158,6 +158,23 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL)
158158 break ;
159159 }
160160 }
161+ if (!out_frame)
162+ { // look in our local out parms next
163+ for (FOutParmRec *rec = OutParms; rec != nullptr ; rec = rec->NextOutParm )
164+ {
165+ if (rec->Property == prop)
166+ {
167+ out_frame = rec->PropAddr - prop->GetOffset_ForUFunction ();
168+ break ;
169+ }
170+ }
171+ }
172+ if (!out_frame)
173+ { // default to our current frame
174+ out_frame = frame;
175+
176+ }
177+
161178 if (!ue_py_convert_pyobject (py_obj, prop, out_frame, 0 ))
162179 {
163180 UE_LOG (LogPython, Error, TEXT (" Failed to convert output property for function %s" ), *function->GetFName ().ToString ());
0 commit comments