From: mfranz Date: Sun, 22 Oct 2006 13:08:09 +0000 (+0000) Subject: - // This will come back and remove X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4f0bfbab2127e13a67958100a17657cc8e93aef0;p=simgear.git - // This will come back and remove - // the current item each time. Is - // that OK? No, it is not OK. This messes up the vector and confuses the iterator. And it leads to crashes. Better read the vector in reverse order. --- diff --git a/simgear/props/props.cxx b/simgear/props/props.cxx index a04f90ca..3ce2687d 100644 --- a/simgear/props/props.cxx +++ b/simgear/props/props.cxx @@ -2286,12 +2286,8 @@ SGPropertyNode::hash_table::hashcode (const char * key) SGPropertyChangeListener::~SGPropertyChangeListener () { - // This will come back and remove - // the current item each time. Is - // that OK? - vector::iterator it; - for (it = _properties.begin(); it != _properties.end(); it++) - (*it)->removeChangeListener(this); + for (int i = _properties.size() - 1; i >= 0; i--) + _properties[i]->removeChangeListener(this); } void