Re: [Flightgear-devel] [Flightgear-cvslogs] CVS: FlightGear/src/Scripting NasalSys.cxx, 1.55, 1.56

2007-01-28 Thread Frederic Bouvier
Melchior,

Selon Melchior Franz :

 --- 435,443 
   _purgeListeners = false;
   mapint, FGNasalListener *::iterator it;
 ! for(it = _listener.end(); --it != _listener.end();) {
   FGNasalListener *nl = it-second;
   if(nl-_dead) {
 ! _listener.erase(it);
   delete nl;
   }
   }

I am pretty sure it is illegal to use an iterator after it was used for erasing
an item. I think the code below is better and works on every systems :

 _purgeListeners = false;
 mapint, FGNasalListener *::iterator it;
 for(it = _listener.end(); --it != _listener.end();) {
 FGNasalListener *nl = it-second;
 if(nl-_dead) {
 mapint, FGNasalListener *::iterator it2 = it++; = use a copy
of the iterator
 _listener.erase(it2); = to erase the item
 delete nl;
 }
 }

But I thing the purpose of reverse iterators is exactly to do that and the use
of them should be more valid in the end.

-Fred

--
Frédéric Bouvier
http://frfoto.free.fr  Photo gallery - album photo
http://www.fotolia.fr/p/2278/partner/2278  Other photo gallery
http://fgsd.sourceforge.net/   FlightGear Scenery Designer

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] [Flightgear-cvslogs] CVS: FlightGear/src/Scripting NasalSys.cxx, 1.55, 1.56

2007-01-28 Thread Melchior FRANZ
* Frederic Bouvier -- Sunday 28 January 2007:
 I am pretty sure it is illegal to use an iterator after it was used for 
 erasing
 an item. I think the code below is better and works on every systems :
[...]
 But I thing the purpose of reverse iterators is exactly to do that and the use
 of them should be more valid in the end.

Sheesh. There's a reason why I usually just use good old
foo.size() with random access.  :-/

m.

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel