summaryrefslogtreecommitdiffstats
path: root/src/util/math.h
diff options
context:
space:
mode:
authorRJ Ryan <rryan@mixxx.org>2014-11-15 15:23:38 -0500
committerRJ Ryan <rryan@mixxx.org>2014-11-15 15:23:38 -0500
commit873835442c437059f0bb0984862c73fa9f937422 (patch)
treee63dc1dd1fc90cebb0d3dc74e729cd9753c7ac75 /src/util/math.h
parentfe33f277891c2db94197f092fd8f574041028140 (diff)
Some fixes to SampleUtil changes:
* Don't use Q_ASSERT since it "crashes" Mixxx from the user perspective. * Don't use std::transform. * Guard math_clamp warnings on developer mode.
Diffstat (limited to 'src/util/math.h')
-rw-r--r--src/util/math.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/util/math.h b/src/util/math.h
index f373092b55..d7d8627021 100644
--- a/src/util/math.h
+++ b/src/util/math.h
@@ -7,7 +7,9 @@
#include <cmath>
#include <algorithm>
-#include <QtDebug> // Q_ASSERT
+#include <QtDebug>
+
+#include "util/cmdlineargs.h"
// If we don't do this then we get the C90 fabs from the global namespace which
// is only defined for double.
@@ -19,16 +21,12 @@ using std::fabs;
template <typename T>
inline T math_clamp(T value, T min, T max) {
- // NOTE(uklotzde): Exceptionally use Q_ASSERT here to detect
- // programming errors early during development. This check should
- // be avoided in the released version for maximum performance!
- //
- // Use two separate assertions for min < max:
- // - min > max is a programming error
- // - min == max is most likely a programming error and avoidable
- // performance burden
- Q_ASSERT(min <= max); // programming error
- Q_ASSERT(min != max); // potential programming error & performance warning
+ // XXX: If max < min, behavior is undefined, and has been causing problems.
+ // if debugging is on, assert when this happens.
+ if (CmdlineArgs::Instance().getDeveloper() && max < min) {
+ qWarning() << "PROGRAMMING ERROR: math_clamp called with max < min! "
+ << max << " " << min;
+ }
return math_max(min, math_min(max, value));
}