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
Files:
4 edited

Legend:

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

    r5738 r5785  
    8484    const RadarViewable* Radar::getFocus()
    8585    {
    86         return *(this->itFocus_);
     86        if (this->itFocus_)
     87            return *(this->itFocus_);
     88        else
     89            return 0;
    8790    }
    8891
     
    101104        SUPER(Radar, tick, dt);
    102105
    103         if (this->focus_ != *(this->itFocus_))
     106        if (this->itFocus_ && (this->focus_ != *(this->itFocus_)))
    104107        {
    105108            // focus object was deleted, release focus
  • code/branches/core5/src/orxonox/overlays/Map.cc

    r5738 r5785  
    290290       for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin();
    291291            it!=ObjectList<orxonox::RadarViewable>::end();
    292             it++)
     292            ++it)
    293293        {
    294294            //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl;
     
    392392        for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin();
    393393            it!=ObjectList<orxonox::Map>::end();
    394             it++)
     394            ++it)
    395395        {
    396396        //Map * m = it->getMap();
  • 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.