diff options
| author | Marc Mutz <[email protected]> | 2025-12-03 11:39:49 +0100 |
|---|---|---|
| committer | Marc Mutz <[email protected]> | 2025-12-06 10:16:02 +0100 |
| commit | 9c01b632faf41a9029bc279b11830a6238abe3b5 (patch) | |
| tree | c756084fa6307ac5bddda3eb1c4ae0d71a04acb5 | |
| parent | 7b09f45c50dd50440f9708f40cc8ed3a979e4d58 (diff) | |
QVectorND: fix qFuzzyCompare() precondition violation
qFuzzyCompare() requires that neither argument is numerically
zero. This cannot be guaranteed for the vector elements.
Fix by using the new QtPrivate::fuzzyCompare() function, which does
things in the correct way.
As a drive-by, put the operators at the beginning of continued lines,
as requested by https://wiki.qt.io/Qt_Coding_Style#Line_breaks Item 2.
Amends the start of the public history.
Pick-to: 6.10 6.8 6.5
Task-number: QTBUG-142020
Change-Id: I55cfb520bda53e12532923005bb1ee6396b124f2
Reviewed-by: Ivan Solovev <[email protected]>
| -rw-r--r-- | src/gui/math3d/qvectornd.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/gui/math3d/qvectornd.cpp b/src/gui/math3d/qvectornd.cpp index ec836cfa56e..ee070b2b5be 100644 --- a/src/gui/math3d/qvectornd.cpp +++ b/src/gui/math3d/qvectornd.cpp @@ -375,7 +375,8 @@ QT_BEGIN_NAMESPACE */ bool qFuzzyCompare(QVector2D v1, QVector2D v2) noexcept { - return qFuzzyCompare(v1.v[0], v2.v[0]) && qFuzzyCompare(v1.v[1], v2.v[1]); + return QtPrivate::fuzzyCompare(v1.v[0], v2.v[0]) + && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1]); } #ifndef QT_NO_VECTOR3D @@ -979,9 +980,9 @@ QVector3D QVector3D::unproject(const QMatrix4x4 &modelView, const QMatrix4x4 &pr */ bool qFuzzyCompare(QVector3D v1, QVector3D v2) noexcept { - return qFuzzyCompare(v1.v[0], v2.v[0]) && - qFuzzyCompare(v1.v[1], v2.v[1]) && - qFuzzyCompare(v1.v[2], v2.v[2]); + return QtPrivate::fuzzyCompare(v1.v[0], v2.v[0]) + && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1]) + && QtPrivate::fuzzyCompare(v1.v[2], v2.v[2]); } #ifndef QT_NO_VECTOR2D @@ -1501,10 +1502,10 @@ QDataStream &operator>>(QDataStream &stream, QVector3D &vector) */ bool qFuzzyCompare(QVector4D v1, QVector4D v2) noexcept { - return qFuzzyCompare(v1.v[0], v2.v[0]) && - qFuzzyCompare(v1.v[1], v2.v[1]) && - qFuzzyCompare(v1.v[2], v2.v[2]) && - qFuzzyCompare(v1.v[3], v2.v[3]); + return QtPrivate::fuzzyCompare(v1.v[0], v2.v[0]) + && QtPrivate::fuzzyCompare(v1.v[1], v2.v[1]) + && QtPrivate::fuzzyCompare(v1.v[2], v2.v[2]) + && QtPrivate::fuzzyCompare(v1.v[3], v2.v[3]); } #ifndef QT_NO_VECTOR2D |
