mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
fix memory leak of EntityMotionState's
This commit is contained in:
parent
97f44b64fc
commit
a97b8b0ea9
2 changed files with 5 additions and 1 deletions
|
@ -37,6 +37,9 @@ EntityMotionState::EntityMotionState(EntityItem* entity)
|
|||
}
|
||||
|
||||
EntityMotionState::~EntityMotionState() {
|
||||
assert(_entity);
|
||||
_entity->setPhysicsInfo(NULL);
|
||||
_entity = NULL;
|
||||
}
|
||||
|
||||
MotionType EntityMotionState::computeMotionType() const {
|
||||
|
|
|
@ -79,10 +79,10 @@ void PhysicsEngine::removeEntityInternal(EntityItem* entity) {
|
|||
if (physicsInfo) {
|
||||
EntityMotionState* motionState = static_cast<EntityMotionState*>(physicsInfo);
|
||||
removeObject(motionState);
|
||||
entity->setPhysicsInfo(NULL);
|
||||
_entityMotionStates.remove(motionState);
|
||||
_incomingChanges.remove(motionState);
|
||||
_outgoingPackets.remove(motionState);
|
||||
delete motionState;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,7 @@ void PhysicsEngine::clearEntitiesInternal() {
|
|||
QSet<EntityMotionState*>::const_iterator stateItr = _entityMotionStates.begin();
|
||||
for (stateItr = _entityMotionStates.begin(); stateItr != _entityMotionStates.end(); ++stateItr) {
|
||||
removeObject(*stateItr);
|
||||
delete (*stateItr);
|
||||
}
|
||||
_entityMotionStates.clear();
|
||||
_incomingChanges.clear();
|
||||
|
|
Loading…
Reference in a new issue