Re: Cppcheck Dangerous iterator usage after erase()-method

2012-09-16 Thread Julien Nabet
On 16/09/2012 12:26, Noel Grandin wrote: On Sat, Sep 15, 2012 at 9:13 PM, Markus Mohrhard wrote: Hey, Here are the lines: 178 void SwBlink::FrmDelete( const SwRootFrm* pRoot ) 179 { 180 for( SwBlinkList::iterator it = aList.begin(); it != aList.end(); ) 181 {

Re: Cppcheck Dangerous iterator usage after erase()-method

2012-09-16 Thread Markus Mohrhard
Hey Noel, >> >> It can't. Line 183 is supposed to be: >> >> aList.erase(it++); >> > > No, it should be >it = aList.erase(it); > > Once you have called erase(), the iterator becomes invalid, so it must > be replaced by the iterator returned by erase(), which returns the > next valid position,

Re: Cppcheck Dangerous iterator usage after erase()-method

2012-09-16 Thread Noel Grandin
On Sat, Sep 15, 2012 at 9:13 PM, Markus Mohrhard wrote: > Hey, > > >> >> Here are the lines: >> 178 void SwBlink::FrmDelete( const SwRootFrm* pRoot ) >> 179 { >> 180 for( SwBlinkList::iterator it = aList.begin(); it != >> aList.end(); ) >> 181 { >> 182 if( pRoot

Re: Cppcheck Dangerous iterator usage after erase()-method

2012-09-15 Thread julien2412
://nabble.documentfoundation.org/Cppcheck-Dangerous-iterator-usage-after-erase-method-tp4007715p4007724.html Sent from the Dev mailing list archive at Nabble.com. ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman

Re: Cppcheck Dangerous iterator usage after erase()-method

2012-09-15 Thread Markus Mohrhard
Hey, > > Here are the lines: > 178 void SwBlink::FrmDelete( const SwRootFrm* pRoot ) > 179 { > 180 for( SwBlinkList::iterator it = aList.begin(); it != > aList.end(); ) > 181 { > 182 if( pRoot == (*it).GetRootFrm() ) > 183 aList.erase( it ); >

Cppcheck Dangerous iterator usage after erase()-method

2012-09-15 Thread julien2412
increment. Any idea? Julien -- View this message in context: http://nabble.documentfoundation.org/Cppcheck-Dangerous-iterator-usage-after-erase-method-tp4007715.html Sent from the Dev mailing list archive at Nabble.com. ___ LibreOffice mail