BGE: The recent physics cleanup was using KX_GameObject::GetParent() with out calling...
authorMitchell Stokes <mogurijin@gmail.com>
Mon, 4 Nov 2013 19:22:52 +0000 (19:22 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Mon, 4 Nov 2013 19:22:52 +0000 (19:22 +0000)
source/gameengine/Ketsji/KX_Scene.cpp

index 1d95beed6e954697b88d6ff7e763e7e3f08f809d..2cddb073b41499ddcb50568071335d5aaac1b35b 100644 (file)
@@ -567,11 +567,16 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
        {
                PHY_IMotionState* motionstate = new KX_MotionState(newobj->GetSGNode());
                PHY_IPhysicsController* newctrl = orgobj->GetPhysicsController()->GetReplica();
-               PHY_IPhysicsController* parentctrl = (newobj->GetParent()) ? newobj->GetParent()->GetPhysicsController() : NULL;
+
+               KX_GameObject *parent = newobj->GetParent();
+               PHY_IPhysicsController* parentctrl = (parent) ? parent->GetPhysicsController() : NULL;
 
                newctrl->SetNewClientInfo(newobj->getClientInfo());
                newobj->SetPhysicsController(newctrl, newobj->IsDynamic());
                newctrl->PostProcessReplica(motionstate, parentctrl);
+
+               if (parent)
+                       parent->Release();
        }
        return newobj;
 }