diff options
-rw-r--r-- | src/gui/graphicsview/qgraphicstransform.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp | 4 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index 06df788..513c41f 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -92,6 +92,7 @@ #include "qgraphicstransform_p.h" #include <QDebug> #include <QtCore/qmath.h> +#include <QtCore/qnumeric.h> #ifndef QT_NO_GRAPHICSVIEW QT_BEGIN_NAMESPACE @@ -467,6 +468,7 @@ void QGraphicsRotation::setOrigin(const QVector3D &point) item will be rotated counter-clockwise. Normally the rotation angle will be in the range (-360, 360), but you can also provide numbers outside of this range (e.g., a angle of 370 degrees gives the same result as 10 degrees). + Setting the angle to NaN results in no rotation. \sa origin */ @@ -570,7 +572,7 @@ void QGraphicsRotation::applyTo(QMatrix4x4 *matrix) const { Q_D(const QGraphicsRotation); - if (d->angle == 0. || d->axis.isNull()) + if (d->angle == 0. || d->axis.isNull() || qIsNaN(d->angle)) return; matrix->translate(d->origin); diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp index 79f2213..d2b6022 100644 --- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp +++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp @@ -215,6 +215,10 @@ void tst_QGraphicsTransform::rotation() rotation.setAngle(90); QCOMPARE(transform2D(rotation).map(QPointF(10, 10)), QPointF(10, 10)); QCOMPARE(transform2D(rotation).map(QPointF(20, 10)), QPointF(10, 20)); + + rotation.setOrigin(QVector3D(0, 0, 0)); + rotation.setAngle(qQNaN()); + QCOMPARE(transform2D(rotation).map(QPointF(20, 10)), QPointF(20, 10)); } Q_DECLARE_METATYPE(Qt::Axis); |