summaryrefslogtreecommitdiff
path: root/libs/evoral/evoral
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-12-31 07:43:43 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2014-12-31 07:43:43 -0500
commite4f61de52fb82c173e9a6e4aee669263fd180b1c (patch)
tree6aa541eb66348e0b5a9c6e6d35e703370cbedfb3 /libs/evoral/evoral
parent9ca0ce4b7fe8dc9c11a64376114b47ca7b3d3836 (diff)
Fix range "arithmetic"
Subtracting anything from an empty range should return an empty range, not an assert() failure
Diffstat (limited to 'libs/evoral/evoral')
-rw-r--r--libs/evoral/evoral/Range.hpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/libs/evoral/evoral/Range.hpp b/libs/evoral/evoral/Range.hpp
index 476970f663..230b289747 100644
--- a/libs/evoral/evoral/Range.hpp
+++ b/libs/evoral/evoral/Range.hpp
@@ -137,6 +137,7 @@ struct /*LIBEVORAL_API*/ Range {
Range (T f, T t) : from (f), to (t) {}
T from; ///< start of the range
T to; ///< end of the range (inclusive: to lies inside the range)
+ bool empty() const { return from == to; }
};
template<typename T>
@@ -215,7 +216,7 @@ RangeList<T> subtract (Range<T> range, RangeList<T> sub)
RangeList<T> result;
result.add (range);
- if (sub.empty ()) {
+ if (sub.empty () || range.empty()) {
return result;
}