diff options
author | Mika Salmela <mika.salmela@digia.com> | 2013-02-13 12:03:35 +0200 |
---|---|---|
committer | Mika Salmela <mika.salmela@digia.com> | 2013-02-13 15:21:13 +0200 |
commit | 4543a29c88914acb73ef0d2678126504b8105e9a (patch) | |
tree | be2cb1ff9354e7a2d5231ac4f34cb99af2156a3d /src/charthelpers_p.h | |
parent | 5eb5ce9ed083c8778992f7a4866b6bf45e4ea806 (diff) |
Fix to discard NaN, Inf and -Inf values from chart.
This correction adds test to several append funtions to test that NaN, Inf
and -Inf values are not added to chart. This solution follows the QPainterPath
behaviour.
Task-number: QTRD-1893
Reviewed-by: Miikka Heikkinen
Diffstat (limited to 'src/charthelpers_p.h')
-rw-r--r-- | src/charthelpers_p.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/charthelpers_p.h b/src/charthelpers_p.h new file mode 100644 index 00000000..63e5cfaf --- /dev/null +++ b/src/charthelpers_p.h @@ -0,0 +1,26 @@ +#ifndef CHARTHELPERS_P_H +#define CHARTHELPERS_P_H + +#include <qnumeric.h> +#include <QPointF> + +static inline bool isValidValue(qreal value) +{ + if (qIsNaN(value) || qIsInf(value)) { + qWarning("Ignored NaN, Inf, or -Inf value."); + return false; + } + return true; +} + +static inline bool isValidValue(qreal x, qreal y) +{ + return (isValidValue(x) && isValidValue(y)); +} + +static inline bool isValidValue(const QPointF point) +{ + return (isValidValue(point.x()) && isValidValue(point.y())); +} + +#endif // CHARTHELPERS_P_H |