Skip to content

Commit de2e570

Browse files
marcmutzQt Cherry-pick Bot
authored andcommitted
QQuaternion: fix qFuzzyCompare() precondition violation
qFuzzyCompare() requires that neither argument is numerically zero. One user of this function cannot guarantee this, because, while they check for zero, they do so _after_ calling qFuzzyCompare() with that value, so the check comes too late. Fix by swapping the two checks around (so we check for == 0 before we check for == 1). Amends 8c1532e, which changed from qFuzzyIsNull(x - 1) (which doesn't have the problem) to qFuzzyCompare(x, 1) (which does). Pick-to: 6.8 6.5 Task-number: QTBUG-142020 Change-Id: I054449b5510217f83479c5a028986c569f54084c Reviewed-by: Ivan Solovev <[email protected]> Reviewed-by: Edward Welbourne <[email protected]> (cherry picked from commit e6f5161) Reviewed-by: Qt Cherry-pick Bot <[email protected]>
1 parent 39a6361 commit de2e570

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/gui/math3d/qquaternion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ QQuaternion QQuaternion::fromAxisAndAngle
409409
(float x, float y, float z, float angle)
410410
{
411411
float length = qHypot(x, y, z);
412-
if (!qFuzzyCompare(length, 1.0f) && !qFuzzyIsNull(length)) {
412+
if (!qFuzzyIsNull(length) && !qFuzzyCompare(length, 1.0f)) {
413413
x /= length;
414414
y /= length;
415415
z /= length;

0 commit comments

Comments
 (0)