BGE Animations: Fixing some refcount issues with KX_Scene::m_animatedlist (fixes...
authorMitchell Stokes <mogurijin@gmail.com>
Fri, 16 Sep 2011 20:08:05 +0000 (20:08 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Fri, 16 Sep 2011 20:08:05 +0000 (20:08 +0000)
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_Scene.cpp

index ae8d709..853b36b 100644 (file)
@@ -364,7 +364,9 @@ BL_ActionManager* KX_GameObject::GetActionManager()
 {
        // We only want to create an action manager if we need it
        if (!m_actionManager)
-       {               KX_GetActiveScene()->AddAnimatedObject(this);           m_actionManager = new BL_ActionManager(this);
+       {               
+               KX_GetActiveScene()->AddAnimatedObject(this);
+               m_actionManager = new BL_ActionManager(this);
        }
        return m_actionManager;
 }
index bdc3081..7ff4a78 100644 (file)
@@ -1034,6 +1034,8 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
                ret = newobj->Release();
        if (m_euthanasyobjects->RemoveValue(newobj))
                ret = newobj->Release();
+       if (m_animatedlist->RemoveValue(newobj))
+               ret = newobj->Release();
                
        if (newobj == m_active_camera)
        {
@@ -1525,6 +1527,7 @@ void KX_Scene::LogicBeginFrame(double curtime)
 
 void KX_Scene::AddAnimatedObject(CValue* gameobj)
 {
+       gameobj->AddRef();
        m_animatedlist->Add(gameobj);
 }
 
@@ -1537,7 +1540,7 @@ void KX_Scene::UpdateAnimations(double curtime)
 {
        // Update any animations
        for (int i=0; i<m_animatedlist->GetCount(); ++i)
-               ((KX_GameObject*)GetObjectList()->GetValue(i))->UpdateActionManager(curtime);
+               ((KX_GameObject*)m_animatedlist->GetValue(i))->UpdateActionManager(curtime);
 }
 
 void KX_Scene::LogicUpdateFrame(double curtime, bool frame)