summaryrefslogtreecommitdiffstats
path: root/src/util/math.h
diff options
context:
space:
mode:
authorOwen Williams <owilliams@mixxx.org>2014-07-16 16:50:51 -0400
committerOwen Williams <owilliams@mixxx.org>2014-07-16 16:50:51 -0400
commit2be0fd8745f21c569a47c57cb9aa1bd8a280756a (patch)
treecea7f17a378d3f7a98b8e779f79e444044aa9610 /src/util/math.h
parent7b4501425643f2ee79325e67a85e2022070124fe (diff)
Warn, don't crash, if math_clamp is used badly
Diffstat (limited to 'src/util/math.h')
-rw-r--r--src/util/math.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/util/math.h b/src/util/math.h
index b425e2cd9b..dee5a90aff 100644
--- a/src/util/math.h
+++ b/src/util/math.h
@@ -6,6 +6,7 @@
#define _USE_MATH_DEFINES
#include <cmath>
#include <algorithm>
+#include <QDebug>
// If we don't do this then we get the C90 fabs from the global namespace which
// is only defined for double.
@@ -19,7 +20,10 @@ template <typename T>
inline T math_clamp(const T& value, const T& min, const T& max) {
// XXX: If max < min, behavior is undefined, and has been causing problems.
// if debugging is on, assert when this happens.
- Q_ASSERT(max >= min);
+ if (max < min) {
+ qWarning() << "PROGRAMMING ERROR: math_clamp called with max < min! "
+ << max << " " << min;
+ }
if (value > max) {
return max;
}