diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-03-10 00:51:38 +0300 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-03-10 00:51:38 +0300 |
commit | 52293831b26f34547acf100603c87296deba7a60 (patch) | |
tree | 1eb228a4a0c8f09170b6cf02a8fbbe4573426a97 /source/gameengine/Ketsji/KX_GameObject.cpp | |
parent | 822e51bd2d663f82d360d474192718660cc9a35c (diff) |
BGE fix: game object to controller links consistancy maintained regardless of order of deletion
AddObject actuator forces last created object to hang in memory even after object is removed from scene => bad link between object and physic controller that causes Blender to crash in case a python script tries to use it (bad programming anyway).
This patch avoids the crash by maintaining consistent links at all time.
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 67c82ee2082..bc608d26c50 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -105,7 +105,19 @@ KX_GameObject::~KX_GameObject() delete m_pClient_info; //if (m_pSGNode) // delete m_pSGNode; - + if (m_pSGNode) + { + // must go through controllers and make sure they will not use us anymore + // This is important for KX_BulletPhysicsControllers that unregister themselves + // from the object when they are deleted. + SGControllerList::iterator contit; + SGControllerList& controllers = m_pSGNode->GetSGControllerList(); + for (contit = controllers.begin();contit!=controllers.end();++contit) + { + (*contit)->ClearObject(); + } + m_pSGNode->SetSGClientObject(NULL); + } } |