diff --git a/app/common/timerange.cpp b/app/common/timerange.cpp index 6656facbe..d8b2a5b6b 100644 --- a/app/common/timerange.cpp +++ b/app/common/timerange.cpp @@ -160,20 +160,25 @@ void TimeRange::normalize() length_ = out_ - in_; } -void TimeRangeList::InsertTimeRange(const TimeRange &range) +void TimeRangeList::InsertTimeRange(TimeRange range_to_add) { + // See if list contains this range + if (ContainsTimeRange(range_to_add)) { + return; + } + + // Does not contain range, so we'll almost certainly be adding it in some way for (int i=0;iremoveAt(i); - i--; - sz--; - - InsertTimeRange(before); - InsertTimeRange(after); + this->append(TimeRange(remove.out(), compare.out())); + compare.set_out(remove.in()); } else if (compare.in() < remove.in() && compare.out() > remove.in()) { // This element's out point overlaps the range's in, we'll trim it compare.set_out(remove.in()); diff --git a/app/common/timerange.h b/app/common/timerange.h index 22b8317fb..de5785b5f 100644 --- a/app/common/timerange.h +++ b/app/common/timerange.h @@ -74,7 +74,7 @@ public: { } - void InsertTimeRange(const TimeRange& range); + void InsertTimeRange(TimeRange range_to_add); void RemoveTimeRange(const TimeRange& remove);