fix crash when PhysicsManager destructs first
This commit is contained in:
parent
a524d4db49
commit
5b2e37764a
|
|
@ -23,9 +23,9 @@
|
|||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void PhysicsManager::
|
||||
attach_physical(Physical *p) {
|
||||
nassertv(p);
|
||||
nassertv(p && p->_physics_manager == NULL);
|
||||
p->_physics_manager = this;
|
||||
pvector< Physical * >::iterator found;
|
||||
PhysicalsVector::iterator found;
|
||||
found = find(_physicals.begin(), _physicals.end(), p);
|
||||
if (found == _physicals.end()) {
|
||||
_physicals.push_back(p);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ PhysicsManager() {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
PhysicsManager::
|
||||
~PhysicsManager() {
|
||||
PhysicalsVector::iterator pi;
|
||||
for (pi = _physicals.begin(); pi != _physicals.end(); ++pi) {
|
||||
nassertv((*pi)->_physics_manager == this);
|
||||
(*pi)->_physics_manager = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -115,7 +120,7 @@ remove_physical(Physical *p) {
|
|||
return;
|
||||
}
|
||||
nassertv(*found == p);
|
||||
nassertv(p->_physics_manager != (PhysicsManager *) NULL);
|
||||
nassertv(p->_physics_manager == this);
|
||||
p->_physics_manager = (PhysicsManager *) NULL;
|
||||
_physicals.erase(found);
|
||||
nassertv(_physicals.end() == find(_physicals.begin(), _physicals.end(), p));
|
||||
|
|
|
|||
Loading…
Reference in New Issue