collision handler pointer may have already been removed

This commit is contained in:
David Rose 2003-05-31 00:16:34 +00:00
parent cf5188d6ba
commit c683d3d834

View File

@ -142,11 +142,14 @@ remove_collider(CollisionNode *node) {
// Update the set of handlers.
Handlers::iterator hi = _handlers.find(handler);
nassertr(hi != _handlers.end(), false);
(*hi).second--;
nassertr((*hi).second >= 0, false);
if ((*hi).second == 0) {
_handlers.erase(hi);
// It's possible that the handler doesn't exist in the list (it may
// have removed itself if it detected some internal error).
if (hi != _handlers.end()) {
(*hi).second--;
nassertr((*hi).second >= 0, false);
if ((*hi).second == 0) {
_handlers.erase(hi);
}
}
_colliders.erase(ci);