← Back to team overview

yade-dev team mailing list archive

Re: [Branch ~yade-dev/yade/trunk] Rev 2961: Add check on body existance in GlobalStiffnessTimeStepper. Fixes LP:891540

 

Bruno Chareyre said:     (by the date of Mon, 21 Nov 2011 23:21:59 +0100)

>        for(  ; bi!=biEnd ; ++bi )
> 
> >        {
> > +               if (!*bi)  continue;
> >                shared_ptr<Body> b = *bi;
> >
> > I it not possible that iterator will return empty pointer. If it
> > does, then it's a bug in the iterator.
> >
> >
> The iterator is not empty, but the pointer it points to can be. Hence the
> crash when somebody delete bodies.
> That is why I suggested to make iterator incrementation jump null bodies.

In fact iterator should not only jump null bodies, but also remove
them from container.

It is the correct way, because even by C++ ISO specification an
iterator must never be empty. This is obviously our definition of
"empty": a deleted body.

> At the moment we are slowly including such boring test in each other loop
> on bodies in yade... It's ugly IMO.

don't do this. It will take a lot of time to clean this up.


-- 
Janek Kozicki                               http://janek.kozicki.pl/  |


Follow ups

References