Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2014-05-01 05:37:47 +0400
committerMitchell Stokes <mogurijin@gmail.com>2014-05-01 05:53:32 +0400
commit60c8c130fed60dc1fe5387b960549385188feadf (patch)
tree20a986e078ec4c79a321e3a2d12cb4a0d22b724c /source/gameengine
parent8d42e7b20d884937f7bf5491b0bddeec3e54b67b (diff)
BGE cleanup: KX_GameObject::GetParent() no longer increases the object's refcount.
I'm not sure why this function ever increased the object's refcount. Any place in the code that calls KX_GameObject::GetParent() has to turn around and call parent->Release(). Forgetting to call Release() was a common cause of memory leaks (in fact, KX_SteeringActuator was probably leaking). If the refcount needs to be increased, the calling code can handle calling AddRef().
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.cpp1
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp3
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp5
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp2
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp7
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp2
8 files changed, 0 insertions, 28 deletions
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
index 0c5e21322df..e5662b54b83 100644
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
@@ -342,7 +342,6 @@ bool KX_ConstraintActuator::Update(double curtime, bool frame)
KX_GameObject *parent = obj->GetParent();
if (parent) {
spc = parent->GetPhysicsController();
- parent->Release();
}
}
KX_RayCast::Callback<KX_ConstraintActuator> callback(this,dynamic_cast<PHY_IPhysicsController*>(spc));
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 2e39614e7d2..7042e6ed360 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -306,9 +306,6 @@ KX_GameObject* KX_GameObject::GetParent()
if (node)
result = (KX_GameObject*)node->GetSGClientObject();
}
-
- if (result)
- result->AddRef();
return result;
@@ -2113,7 +2110,6 @@ PyObject *KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DE
KX_GameObject* self = static_cast<KX_GameObject*>(self_v);
KX_GameObject* parent = self->GetParent();
if (parent) {
- parent->Release(); /* self->GetParent() AddRef's */
return parent->GetProxy();
}
Py_RETURN_NONE;
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
index 84e615b61ab..0f47dfd922b 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ b/source/gameengine/Ketsji/KX_RaySensor.cpp
@@ -265,9 +265,6 @@ bool KX_RaySensor::Evaluate()
if (!spc && parent)
spc = parent->GetPhysicsController();
- if (parent)
- parent->Release();
-
PHY_IPhysicsEnvironment* physics_environment = this->m_scene->GetPhysicsEnvironment();
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 65f5ff15501..b2dca147f67 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -575,9 +575,6 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
newctrl->SetNewClientInfo(newobj->getClientInfo());
newobj->SetPhysicsController(newctrl, newobj->IsDynamic());
newctrl->PostProcessReplica(motionstate, parentctrl);
-
- if (parent)
- parent->Release();
}
return newobj;
@@ -758,8 +755,6 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level)
KX_GameObject *parent = gameobj->GetParent();
if (parent != NULL)
{
- parent->Release(); // GetParent() increased the refcount
-
// this object is not a top parent. Either it is the child of another
// object in the group and it will be added automatically when the parent
// is added. Or it is the child of an object outside the group and the group
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp
index 1b8ef09aec8..5cb1d5f3620 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.cpp
+++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp
@@ -208,10 +208,6 @@ bool KX_TouchSensor::BroadPhaseSensorFilterCollision(void*obj1,void*obj2)
KX_ClientObjectInfo *my_client_info = static_cast<KX_ClientObjectInfo*>(m_physCtrl->GetNewClientInfo());
KX_GameObject* otherobj = ( client_info ? client_info->m_gameobject : NULL);
- // first, decrement refcount as GetParent() increases it
- if (myparent)
- myparent->Release();
-
// we can only check on persistent characteristic: m_link and m_suspended are not
// good candidate because they are transient. That must be handled at another level
if (!otherobj ||
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
index 44a6e2fd7ee..90b7850946b 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
@@ -79,8 +79,6 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj,
m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation();
// use registration mechanism rather than AddRef, it creates zombie objects
m_parentobj->RegisterActuator(this);
- // GetParent did AddRef, undo here
- m_parentobj->Release();
}
}
}
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 966afa0e7f2..3c9c5d0a239 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -3200,8 +3200,6 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject
{
delete motionstate;
shapeInfo->Release();
- if (parent)
- parent->Release();
return;
}
@@ -3254,8 +3252,6 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject
shapeInfo->Release();
// delete motionstate as it's not used
delete motionstate;
- if (parent)
- parent->Release();
return;
}
@@ -3432,7 +3428,4 @@ void CcdPhysicsEnvironment::ConvertObject(KX_GameObject *gameobj, RAS_MeshObject
}
}
#endif
-
- if (parent)
- parent->Release();
}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 1227fe892a3..0960fdaab4f 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -1375,8 +1375,6 @@ void RAS_OpenGLRasterizer::applyTransform(double* oglmatrix,int objectdrawmode )
KX_GameObject *parent = gameobj->GetParent();
if (!physics_controller && parent)
physics_controller = parent->GetPhysicsController();
- if (parent)
- parent->Release();
KX_RayCast::Callback<RAS_OpenGLRasterizer> callback(this, physics_controller, oglmatrix);
if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))