Skip to content

Commit 5298b9f

Browse files
committed
added exec_in_main_thread() to mac
1 parent dad6583 commit 5298b9f

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,23 @@ static PyObject *py_unreal_engine_exec(PyObject * self, PyObject * args)
164164
Py_RETURN_NONE;
165165
}
166166

167+
168+
#if PLATFORM_MAC
169+
static PyObject *py_unreal_engine_exec_in_main_thread(PyObject * self, PyObject * args)
170+
{
171+
char *filename = nullptr;
172+
if (!PyArg_ParseTuple(args, "s:exec_in_main_thread", &filename))
173+
{
174+
return NULL;
175+
}
176+
FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked<FUnrealEnginePythonModule>("UnrealEnginePython");
177+
Py_BEGIN_ALLOW_THREADS;
178+
PythonModule.RunFileInMainThread(filename);
179+
Py_END_ALLOW_THREADS;
180+
Py_RETURN_NONE;
181+
}
182+
#endif
183+
167184
static PyObject *py_ue_get_py_proxy(ue_PyUObject *self, PyObject * args)
168185
{
169186

@@ -398,6 +415,10 @@ static PyMethodDef unreal_engine_methods[] = {
398415
{ "exec", py_unreal_engine_exec, METH_VARARGS, "" },
399416
#endif
400417
{ "py_exec", py_unreal_engine_exec, METH_VARARGS, "" },
418+
#if PLATFORM_MAC
419+
{ "exec_in_main_thread", py_unreal_engine_exec_in_main_thread, METH_VARARGS, "" },
420+
{ "py_exec_in_main_thread", py_unreal_engine_exec_in_main_thread, METH_VARARGS, "" },
421+
#endif
401422

402423
{ "get_engine_defined_action_mappings", py_unreal_engine_get_engine_defined_action_mappings, METH_VARARGS, "" },
403424

0 commit comments

Comments
 (0)