mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 06:17:28 +02:00
Merge pull request #7823 from Atlante45/fix/potential-it-invalidation
Fix potential iterator invalidation
This commit is contained in:
commit
aeebf7d9bf
1 changed files with 2 additions and 6 deletions
|
@ -225,9 +225,7 @@ void PhysicsEngine::removeContacts(ObjectMotionState* motionState) {
|
||||||
ContactMap::iterator contactItr = _contactMap.begin();
|
ContactMap::iterator contactItr = _contactMap.begin();
|
||||||
while (contactItr != _contactMap.end()) {
|
while (contactItr != _contactMap.end()) {
|
||||||
if (contactItr->first._a == motionState || contactItr->first._b == motionState) {
|
if (contactItr->first._a == motionState || contactItr->first._b == motionState) {
|
||||||
ContactMap::iterator iterToDelete = contactItr;
|
contactItr = _contactMap.erase(contactItr);
|
||||||
++contactItr;
|
|
||||||
_contactMap.erase(iterToDelete);
|
|
||||||
} else {
|
} else {
|
||||||
++contactItr;
|
++contactItr;
|
||||||
}
|
}
|
||||||
|
@ -386,9 +384,7 @@ const CollisionEvents& PhysicsEngine::getCollisionEvents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == CONTACT_EVENT_TYPE_END) {
|
if (type == CONTACT_EVENT_TYPE_END) {
|
||||||
ContactMap::iterator iterToDelete = contactItr;
|
contactItr = _contactMap.erase(contactItr);
|
||||||
++contactItr;
|
|
||||||
_contactMap.erase(iterToDelete);
|
|
||||||
} else {
|
} else {
|
||||||
++contactItr;
|
++contactItr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue