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 <lars.knoll@qt.io>
This commit is contained in:
Eirik Aavitsland 2020-10-28 16:31:44 +01:00
parent bd3a1dd9c2
commit 7aa68ee6f2
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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);