Skip to content

Commit d545a7e

Browse files
Iakhin, RuslanIakhin, Ruslan
authored andcommitted
Function end_play is not mandatory
1 parent 429afbd commit d545a7e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Source/UnrealEnginePython/Private/PythonComponent.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,15 @@ void UPythonComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
107107

108108
FScopePythonGIL gil;
109109

110-
PyObject *ep_ret = PyObject_CallMethod(py_component_instance, (char *)"end_play", NULL);
110+
if (PyObject_HasAttrString(py_component_instance, (char *)"end_play")) {
111+
PyObject *ep_ret = PyObject_CallMethod(py_component_instance, (char *)"end_play", NULL);
111112

112-
if (!ep_ret) {
113-
unreal_engine_py_log_error();
114-
}
113+
if (!ep_ret) {
114+
unreal_engine_py_log_error();
115+
}
115116

116-
Py_XDECREF(ep_ret);
117+
Py_XDECREF(ep_ret);
118+
}
117119

118120
Super::EndPlay(EndPlayReason);
119121

0 commit comments

Comments
 (0)