1d978429f5
simgear/props/props_test.cxx: test for self-unregister. SGPropertyNode::removeChangeListener() used to modify the _listeners vector or even delete it and set _listeners to NULL, if a listener was removed. This could cause a SEGV if removeChangeListener() was called from a listener, because listeners are called from methods such as SGPropertyNode::fireValueChanged() which iterate through _listeners and don't expect it to be changed to NULL. The fix here is to keep a track of whether we are iterating through the _listeners vector; if we are, SGPropertyNode::removeChangeListener() sets the entry to NULL, instead of removing it. We have a new internal function forEachListener() which takes care of the iterating details - incrementing/decrementing the new _listeners->_num_iterators count and skipping NULL entries. Before returning, if _num_iterators is now zero it removes any NULL entries in the vector of listeners. The nListeners() member is no longer inline, because it needs to ignore NULL entries in the vector. And _listeners now points to an internally-defined struct which contains a new _num_iterators as well as the vector of listeners. Added self-unregister test to simgear/props/props_test.cxx. |
||
---|---|---|
.. | ||
.gitignore | ||
AtomicChangeListener.cxx | ||
AtomicChangeListener.hxx | ||
CMakeLists.txt | ||
condition.cxx | ||
condition.hxx | ||
easing_functions_test.cxx | ||
easing_functions.cxx | ||
easing_functions.hxx | ||
ExtendedPropertyAdapter.hxx | ||
PropertyBasedElement.cxx | ||
PropertyBasedElement.hxx | ||
PropertyBasedMgr.cxx | ||
PropertyBasedMgr.hxx | ||
PropertyInterpolationMgr.cxx | ||
PropertyInterpolationMgr.hxx | ||
PropertyInterpolator.cxx | ||
PropertyInterpolator.hxx | ||
propertyObject_test.cxx | ||
propertyObject.cxx | ||
propertyObject.hxx | ||
props_io.cxx | ||
props_io.hxx | ||
props_test.cxx | ||
props.cxx | ||
props.hxx | ||
propsfwd.hxx | ||
tiedpropertylist.hxx | ||
vectorPropTemplates.hxx |