Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 25, 2009, 12:54:12 AM (16 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/libraries/core/ClassTreeMask.h

    r5738 r5785  
    265265
    266266            /** @brief Returns true if the ClassTreeMaskObjectIterator points at the given object. @param pointer The pointer of the object */
    267             inline bool operator==(BaseObject* pointer) const { return ((*this->objectIterator_) == pointer); }
     267            inline bool operator==(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) == pointer) || (!this->objectIterator_ && pointer == 0); }
    268268            /** @brief Returns true if the ClassTreeMaskObjectIterator doesn't point at the given object. @param pointer The pointer of the object */
    269             inline bool operator!=(BaseObject* pointer) const { return ((*this->objectIterator_) != pointer); }
     269            inline bool operator!=(BaseObject* pointer) const { return (this->objectIterator_ && (*this->objectIterator_) != pointer) || (!this->objectIterator_ && pointer != 0); }
    270270            /** @brief Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end. */
    271271            inline operator bool() const { return (this->objectIterator_); }
Note: See TracChangeset for help on using the changeset viewer.