mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
fix crash when PhysicsManager destructs first
This commit is contained in:
parent
a524d4db49
commit
5b2e37764a
@ -23,9 +23,9 @@
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE void PhysicsManager::
|
INLINE void PhysicsManager::
|
||||||
attach_physical(Physical *p) {
|
attach_physical(Physical *p) {
|
||||||
nassertv(p);
|
nassertv(p && p->_physics_manager == NULL);
|
||||||
p->_physics_manager = this;
|
p->_physics_manager = this;
|
||||||
pvector< Physical * >::iterator found;
|
PhysicalsVector::iterator found;
|
||||||
found = find(_physicals.begin(), _physicals.end(), p);
|
found = find(_physicals.begin(), _physicals.end(), p);
|
||||||
if (found == _physicals.end()) {
|
if (found == _physicals.end()) {
|
||||||
_physicals.push_back(p);
|
_physicals.push_back(p);
|
||||||
|
@ -45,6 +45,11 @@ PhysicsManager() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
PhysicsManager::
|
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;
|
return;
|
||||||
}
|
}
|
||||||
nassertv(*found == p);
|
nassertv(*found == p);
|
||||||
nassertv(p->_physics_manager != (PhysicsManager *) NULL);
|
nassertv(p->_physics_manager == this);
|
||||||
p->_physics_manager = (PhysicsManager *) NULL;
|
p->_physics_manager = (PhysicsManager *) NULL;
|
||||||
_physicals.erase(found);
|
_physicals.erase(found);
|
||||||
nassertv(_physicals.end() == find(_physicals.begin(), _physicals.end(), p));
|
nassertv(_physicals.end() == find(_physicals.begin(), _physicals.end(), p));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user