Use our macro for FP comparisons

I think that catches all the ones we missed (thanks clang -Wfloat-equal).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-02-10 20:43:21 -08:00
parent 2bd2df0349
commit 6ea6a4305c
3 changed files with 8 additions and 8 deletions

View file

@ -246,7 +246,7 @@ void DivePlannerGraphics::keyLeftAction()
double xpos = timeLine->posAtValue((dp.time - 60) / 60); double xpos = timeLine->posAtValue((dp.time - 60) / 60);
bool nextStep = false; bool nextStep = false;
Q_FOREACH(DiveHandler *h, handles) { Q_FOREACH(DiveHandler *h, handles) {
if (h->pos().x() == xpos) { if (IS_FP_SAME(h->pos().x(), xpos)) {
nextStep = true; nextStep = true;
break; break;
} }
@ -274,7 +274,7 @@ void DivePlannerGraphics::keyRightAction()
double xpos = timeLine->posAtValue((dp.time + 60) / 60); double xpos = timeLine->posAtValue((dp.time + 60) / 60);
bool nextStep = false; bool nextStep = false;
Q_FOREACH(DiveHandler *h, handles) { Q_FOREACH(DiveHandler *h, handles) {
if (h->pos().x() == xpos) { if (IS_FP_SAME(h->pos().x(), xpos)) {
nextStep = true; nextStep = true;
break; break;
} }

View file

@ -42,7 +42,7 @@ double DiveCartesianAxis::tickSize() const
void DiveCartesianAxis::setMaximum(double maximum) void DiveCartesianAxis::setMaximum(double maximum)
{ {
if (max == maximum) if (IS_FP_SAME(max, maximum))
return; return;
max = maximum; max = maximum;
emit maxChanged(); emit maxChanged();
@ -50,7 +50,7 @@ void DiveCartesianAxis::setMaximum(double maximum)
void DiveCartesianAxis::setMinimum(double minimum) void DiveCartesianAxis::setMinimum(double minimum)
{ {
if (min == minimum) if (IS_FP_SAME(min, minimum))
return; return;
min = minimum; min = minimum;
} }
@ -348,7 +348,7 @@ QLineF DiveCartesianPlane::horizontalLine() const
void DiveCartesianPlane::setHorizontalLine(QLineF line) void DiveCartesianPlane::setHorizontalLine(QLineF line)
{ {
if ( horizontalSize == line.length()) if (IS_FP_SAME(horizontalSize, line.length()))
return; return;
horizontalSize = line.length(); horizontalSize = line.length();
setup(); setup();
@ -356,7 +356,7 @@ void DiveCartesianPlane::setHorizontalLine(QLineF line)
void DiveCartesianPlane::setVerticalLine(QLineF line) void DiveCartesianPlane::setVerticalLine(QLineF line)
{ {
if (verticalSize == line.length()) if (IS_FP_SAME(verticalSize, line.length()))
return; return;
verticalSize = line.length(); verticalSize = line.length();
setup(); setup();
@ -439,7 +439,7 @@ void PartialGasPressureAxis::preferencesChanged()
max = model->po2Max(); max = model->po2Max();
qreal pp = floor(max * 10.0) / 10.0 + 0.2; qreal pp = floor(max * 10.0) / 10.0 + 0.2;
if (maximum() == pp) if (IS_FP_SAME(maximum(), pp))
return; return;
setMaximum(pp); setMaximum(pp);

View file

@ -571,7 +571,7 @@ void ProfileGraphicsView::plot_pp_text()
QGraphicsLineItem *item = new QGraphicsLineItem(SCALEGC(0, m), SCALEGC(hpos, m)); QGraphicsLineItem *item = new QGraphicsLineItem(SCALEGC(0, m), SCALEGC(hpos, m));
QPen pen(defaultPen); QPen pen(defaultPen);
pen.setColor(c); pen.setColor(c);
if ( QString::number(m).toDouble() != QString::number(m).toInt()) { if ( IS_FP_SAME(QString::number(m).toDouble(), QString::number(m).toInt())) {
pen.setStyle(Qt::DashLine); pen.setStyle(Qt::DashLine);
pen.setWidthF(1.2); pen.setWidthF(1.2);
} }