From b5d254445ceb889dfb146a134b8ec5b638b4a9d2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 25 Aug 2008 09:52:38 +0000 Subject: getting the last created object would return an object that had no SG_Node which would crash whenever python tried to get its location. since the object was removed from the scene anyway, there is no reason to return it. --- source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp index ca0106d64d9..7e0d0df1ab7 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp @@ -377,7 +377,10 @@ PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject(PyObject* self, PyObject* kwds) { SCA_IObject* result = this->GetLastCreatedObject(); - if (result) + + // if result->GetSGNode() is NULL + // it means the object has ended, The BGE python api crashes in many places if the object is returned. + if (result && (static_cast(result))->GetSGNode()) { result->AddRef(); return result; -- cgit v1.2.3