Access to free'd memory correction inside CellWidget::unselectAll().

Do not iterate over a STL set while erasing (all) elements...
The set is stable over erasure, but if the iterator is pointing
to the erased element we cannot do a "++". Increment first, erase
after.
This commit is contained in:
Jean-Paul Chaput 2008-09-21 10:48:08 +00:00
parent a54d86924f
commit 4c998aed83
1 changed files with 3 additions and 4 deletions

View File

@ -1188,10 +1188,9 @@ namespace Hurricane {
void CellWidget::unselectAll ( bool delayRedraw )
{
set<Selector*>::iterator iselector = _selectors.begin ();
for ( ; iselector != _selectors.end() ; iselector++ ) {
(*iselector)->detachFrom ( this );
}
set<Selector*>::iterator iselector;
while ( !_selectors.empty() )
(*_selectors.begin())->detachFrom ( this );
_selectionHasChanged = true;
if ( !delayRedraw ) redraw ();