diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index c0e2bf6e2fe..768e92a15bf 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -1609,7 +1609,7 @@ QPolygon QTransform::mapToPolygon(const QRect &rect) const */ bool QTransform::squareToQuad(const QPolygonF &quad, QTransform &trans) { - if (quad.size() != 4) + if (quad.size() != (quad.isClosed() ? 5 : 4)) return false; qreal dx0 = quad[0].x(); diff --git a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp index 9da3cb568dd..73b66775cea 100644 --- a/tests/auto/gui/painting/qtransform/tst_qtransform.cpp +++ b/tests/auto/gui/painting/qtransform/tst_qtransform.cpp @@ -35,6 +35,7 @@ private slots: void mapInt(); void mapPathWithPoint(); void mapRectToPolygon(); // QTBUG-127723 + void quadToQuad(); // QTBUG-21329 private: void mapping_data(); @@ -714,6 +715,14 @@ void tst_QTransform::mapRectToPolygon() QCOMPARE(polygon1, polygon2); } +void tst_QTransform::quadToQuad() // QTBUG-21329 +{ + QTransform result; + QVERIFY(QTransform::quadToQuad(QRectF(0, 0, 1, 1), QRectF(0, 0, 1, 1), result)); + QPolygonF trapezoid({{0, 0}, {10, 0}, {11, 11}, {0, 10}}); + QVERIFY(QTransform::quadToQuad(trapezoid, trapezoid.boundingRect(), result)); +} + QTEST_APPLESS_MAIN(tst_QTransform)