From e4f61de52fb82c173e9a6e4aee669263fd180b1c Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 31 Dec 2014 07:43:43 -0500 Subject: [PATCH] Fix range "arithmetic" Subtracting anything from an empty range should return an empty range, not an assert() failure --- libs/evoral/evoral/Range.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 @@ -215,7 +216,7 @@ RangeList subtract (Range range, RangeList sub) RangeList result; result.add (range); - if (sub.empty ()) { + if (sub.empty () || range.empty()) { return result; }