Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I think the problem is your delete loop. You erase an object in the loop with list.erase(). The good thing about erase is that it automatically adjusts the list iterator. So your percepIter++ skips some of the list entries.

 for (list<percepUnit*>::iterator percepIter = scratchPercepUnitsForeground.begin(); 
             percepIter != scratchPercepUnitsForeground.end();) {

            delete *percepIter; // delete what we point to.
            percepIter = scratchPercepUnitsForeground.erase(percepIter); // remove the pointer itself, and update the iterator.
        }

Hopefully Im right :)