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.
This commit is contained in:
Campbell Barton 2008-08-25 09:52:38 +00:00
parent 1ed408e8c6
commit b5d254445c

@ -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<KX_GameObject *>(result))->GetSGNode())
{
result->AddRef();
return result;