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.

Location:
code/branches/core5/src/orxonox/pickup
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/orxonox/pickup/DroppedItem.cc

    r5738 r5785  
    5656        if (this->item_)
    5757        {
    58             for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); it++)
     58            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    5959            {
    6060                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
  • code/branches/core5/src/orxonox/pickup/PickupSpawner.cc

    r5738 r5785  
    127127        if (this->isActive())
    128128        {
    129             for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); it++)
     129            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
    130130            {
    131131                Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
Note: See TracChangeset for help on using the changeset viewer.