diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2024-04-05 14:48:09 +0200 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2024-05-10 15:33:40 +0200 |
commit | 7072030d933e0575bab46994406530c8c1f81f5d (patch) | |
tree | 68ecd22e90b29aaeb94db7fb2f83a95cd7cf6851 /src/corelib/tools/qline.h | |
parent | 2a847dd93b1b9cc363eefa27686d78a4bc399d1e (diff) |
Fix QLineF::isNull behavior when handling zero points
QLineF::isNull was using qFuzzyCompare on the x and y components of its
points, which was not working correctly if some of the components was
equal to zero. The correct approach is to use qFuzzyIsNull togeter with
qFuzzyCompare. This approach is already implemented in qFuzzyCompare()
overload for QPointF, so just use it.
Add unit-tests for QLine(F)::isNull.
[ChangeLog][QtCore][QLineF] Fixed a bug when QLineF::isNull() returned
incorrect result if the start or end point contained a zero component.
Change-Id: I3cfe6406b1299de32fe82b1fcbfb0416f0eaac15
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qline.h')
-rw-r--r-- | src/corelib/tools/qline.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h index 45f0bae94f..1d43b7e705 100644 --- a/src/corelib/tools/qline.h +++ b/src/corelib/tools/qline.h @@ -305,7 +305,7 @@ constexpr inline qreal QLineF::y2() const constexpr inline bool QLineF::isNull() const { - return qFuzzyCompare(pt1.x(), pt2.x()) && qFuzzyCompare(pt1.y(), pt2.y()); + return qFuzzyCompare(pt1, pt2); } constexpr inline QPointF QLineF::p1() const |