getting the last created object would return an object that had no SG_Node which...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 25 Aug 2008 09:52:38 +0000 (09:52 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 25 Aug 2008 09:52:38 +0000 (09:52 +0000)
since the object was removed from the scene anyway, there is no reason to return it.

source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp

index ca0106d64d957e34cda49e850ffebb2276e43c63..7e0d0df1ab7bd45795bc22d6dfd83be8cef5c02d 100644 (file)
@@ -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;