From 7aa68ee6f2e08ce0b4f5c698a8c012895f738dd2 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Wed, 28 Oct 2020 16:31:44 +0100 Subject: [PATCH] Fix misidentification of some shearing QTransforms as only rotating The dot product used rows instead of columns. Pick-to: 5.15 5.12 Fixes: QTBUG-87984 Change-Id: I922f67ed0fa9a4f88aa4e9fc6d3c09f8dda21688 Reviewed-by: Lars Knoll --- src/gui/painting/qtransform.cpp | 2 +- tests/auto/gui/painting/qtransform/tst_qtransform.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index bfb0e6f4ec1..34dd425fef3 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -2046,7 +2046,7 @@ QTransform::TransformationType QTransform::type() const case TxShear: case TxRotate: if (!qFuzzyIsNull(m_matrix[0][1]) || !qFuzzyIsNull(m_matrix[1][0])) { - const qreal dot = m_matrix[0][0] * m_matrix[0][1] + m_matrix[1][0] * m_matrix[1][1]; + const qreal dot = m_matrix[0][0] * m_matrix[1][0] + m_matrix[0][1] * m_matrix[1][1]; if (qFuzzyIsNull(dot)) m_type = TxRotate; else diff --git a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp index 2dcb564e2ba..a3ff1b0081d 100644 --- a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp +++ b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp @@ -384,8 +384,9 @@ void tst_QTransform::types() QCOMPARE(m1.inverted().type(), QTransform::TxScale); m1.rotate(45.0f); - QCOMPARE(m1.type(), QTransform::TxRotate); - QCOMPARE(m1.inverted().type(), QTransform::TxRotate); + // Rotation after non-uniform scaling -> shearing. Uniform scale + rotate tested below. + QCOMPARE(m1.type(), QTransform::TxShear); + QCOMPARE(m1.inverted().type(), QTransform::TxShear); m1.shear(0.5f, 0.25f); QCOMPARE(m1.type(), QTransform::TxShear);