Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 25, 2009, 12:54:12 AM (15 years ago)
Author:
landauf
Message:

Removed end-iterator-safety from Iterator and ObjectListIterator. This means, when you reach end(), don't use *it anymore (this returned 0 in the past, now you'll get a segfault).
Changed ClassTreeMask and Radar accordingly.

Also, please always use "for (…) { (it++)→function() }" instead of "for (…; ++it) { it→function() }" if there's a chance function() destroys the object pointed by the iterator. Our objectlists are deletionsafe, but you'll encounter strange problems like overleaped elements and run-over-end() situations if you use the second pattern and don't doublecheck the iterator in the loop.
Changed GSRoot accordingly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/modules/gamestates/GSRoot.cc

    r5738 r5785  
    111111        }
    112112
    113         for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
    114             it->tick(time);
     113        for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; )
     114            (it++)->tick(time);
    115115
    116116        /*** HACK *** HACK ***/
     
    122122            leveldt = 0.0f;
    123123        }
    124         for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    125             it->tick(leveldt * this->timeFactor_);
     124        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; )
     125            (it++)->tick(leveldt * this->timeFactor_);
    126126        /*** HACK *** HACK ***/
    127127    }
Note: See TracChangeset for help on using the changeset viewer.