rational: assert when limits are used for calculations

These will necessarily result in overflows or underflows so I've attempted to weed this behavior out while adding asserts in case there are still usages I haven't found
This commit is contained in:
itsmattkc
2022-04-25 14:26:07 -07:00
parent 4536ed87a5
commit abb84aa2ca
3 changed files with 15 additions and 2 deletions
+6 -1
View File
@@ -44,6 +44,7 @@ const rational &TimeRange::out() const
const rational &TimeRange::length() const
{
Q_ASSERT(!length_.isNaN());
return length_;
}
@@ -173,7 +174,11 @@ void TimeRange::normalize()
}
// Calculate length
length_ = out_ - in_;
if (out_ == RATIONAL_MIN || out_ == RATIONAL_MAX || in_ == RATIONAL_MIN || in_ == RATIONAL_MAX) {
length_ = rational::NaN;
} else {
length_ = out_ - in_;
}
}
void TimeRangeList::insert(const TimeRangeList &list_to_add)