diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-08-25 13:52:38 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-08-25 13:52:38 +0400 |
commit | b5d254445ceb889dfb146a134b8ec5b638b4a9d2 (patch) | |
tree | 34d87438e729c41345a5cf37c3f7726b1750ed8c /source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | |
parent | 1ed408e8c6f835571cbe8176b50500d146a143b2 (diff) |
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.
Diffstat (limited to 'source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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<KX_GameObject *>(result))->GetSGNode()) { result->AddRef(); return result; |