From fe4e45e386ac1c6aac1d4e30fd718d446d5cc8ad Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Mon, 16 Nov 2020 01:33:53 +1100 Subject: [PATCH] fixed timerangelist removing bug --- app/common/timerange.cpp | 25 ++++++++++++------------- app/common/timerange.h | 8 ++++++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/app/common/timerange.cpp b/app/common/timerange.cpp index c53524863..639b5c030 100644 --- a/app/common/timerange.cpp +++ b/app/common/timerange.cpp @@ -78,11 +78,11 @@ bool TimeRange::operator!=(const TimeRange &r) const bool TimeRange::OverlapsWith(const TimeRange &a, bool in_inclusive, bool out_inclusive) const { - bool overlaps_in = (in_inclusive) ? (a.out() < in()) : (a.out() <= in()); + bool doesnt_overlap_in = (in_inclusive) ? (a.out() < in()) : (a.out() <= in()); - bool overlaps_out = (out_inclusive) ? (a.in() > out()) : (a.in() >= out()); + bool doesnt_overlap_out = (out_inclusive) ? (a.in() > out()) : (a.in() >= out()); - return !(overlaps_in || overlaps_out); + return !doesnt_overlap_in && !doesnt_overlap_out; } TimeRange TimeRange::Combined(const TimeRange &a) const @@ -211,8 +211,10 @@ void TimeRangeList::remove(const TimeRange &remove) sz--; } else if (compare.Contains(remove, false, false)) { // The remove range is within this element, only choice is to split the element into two - array_.append(TimeRange(remove.out(), compare.out())); + TimeRange new_range(remove.out(), compare.out()); compare.set_out(remove.in()); + insert(new_range); + break; } 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()); @@ -289,15 +291,6 @@ TimeRangeList TimeRangeList::Intersects(const TimeRange &range) const return intersect_list; } -void TimeRangeList::PrintTimeList() -{ - qDebug() << "TimeRangeList now contains:"; - - for (int i=0;i& internal_array() const + { + return array_; + } +private: QVector array_; }; @@ -139,6 +142,7 @@ uint qHash(const TimeRange& r, uint seed); OLIVE_NAMESPACE_EXIT QDebug operator<<(QDebug debug, const OLIVE_NAMESPACE::TimeRange& r); +QDebug operator<<(QDebug debug, const OLIVE_NAMESPACE::TimeRangeList& r); Q_DECLARE_METATYPE(OLIVE_NAMESPACE::TimeRange)