1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-26 01:18:06 +02:00

Precautions also in TrackIterRange::StaringWith() as in EndingAfter()

This commit is contained in:
Paul Licameli 2018-10-30 11:33:31 -04:00
parent 74a360f682
commit 26abe0255d

View File

@ -980,7 +980,8 @@ private:
return !this->mPred || this->mPred( pTrack ); return !this->mPred || this->mPred( pTrack );
} }
// This friendship is needed in TrackIterRange::EndingAfter() // This friendship is needed in TrackIterRange::StartingWith and
// TrackIterRange::EndingAfter()
friend TrackIterRange< TrackType >; friend TrackIterRange< TrackType >;
// The class invariant is that mIter == mEnd, or else, mIter != mEnd and // The class invariant is that mIter == mEnd, or else, mIter != mEnd and
@ -1057,9 +1058,15 @@ template <
TrackIterRange StartingWith( const Track *pTrack ) const TrackIterRange StartingWith( const Track *pTrack ) const
{ {
auto newBegin = this->find( pTrack );
// More careful construction is needed so that the independent
// increment and decrement of each iterator in the NEW pair
// has the expected behavior at boundaries of the range
return { return {
this->find( pTrack ), { newBegin.mIter, newBegin.mIter, this->second.mEnd,
this->second this->first.GetPredicate() },
{ newBegin.mIter, this->second.mEnd, this->second.mEnd,
this->second.GetPredicate() }
}; };
} }