summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/tools/qpoint.h5
-rw-r--r--tests/auto/corelib/tools/qpointf/tst_qpointf.cpp3
2 files changed, 5 insertions, 3 deletions
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index ae46f0d39f..d7323f7707 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -351,9 +351,8 @@ QT_WARNING_DISABLE_GCC("-Wfloat-equal")
Q_DECL_CONSTEXPR inline bool operator==(const QPointF &p1, const QPointF &p2)
{
- return ((!p1.xp && !p1.yp) || (!p2.xp && !p2.yp))
- ? (qFuzzyIsNull(p1.xp - p2.xp) && qFuzzyIsNull(p1.yp - p2.yp))
- : (qFuzzyCompare(p1.xp, p2.xp) && qFuzzyCompare(p1.yp, p2.yp));
+ return ((!p1.xp || !p2.xp) ? qFuzzyIsNull(p1.xp - p2.xp) : qFuzzyCompare(p1.xp, p2.xp))
+ && ((!p1.yp || !p2.yp) ? qFuzzyIsNull(p1.yp - p2.yp) : qFuzzyCompare(p1.yp, p2.yp));
}
Q_DECL_CONSTEXPR inline bool operator!=(const QPointF &p1, const QPointF &p2)
diff --git a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
index 579991a912..d4ccdf7ba6 100644
--- a/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
+++ b/tests/auto/corelib/tools/qpointf/tst_qpointf.cpp
@@ -450,6 +450,9 @@ void tst_QPointF::compare()
p3 -= QPointF(0.1, 0.1);
QVERIFY(p3 == QPointF());
+
+ // Test we can compare one dimension with hard zero
+ QVERIFY(QPointF(1.9543e-14, -32.0) == QPointF(0.0, -32.0));
}
QTEST_MAIN(tst_QPointF)