diff options
-rw-r--r-- | src/gui/painting/qpainterpath.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qpainterpath/tst_qpainterpath.cpp | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index b0515cc..453726f 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -2915,9 +2915,12 @@ QPointF QPainterPath::pointAtPercent(qreal t) const return QPointF(); } - if (isEmpty()) + if (!d_ptr || d_ptr->elements.size() == 0) return QPointF(); + if (d_ptr->elements.size() == 1) + return d_ptr->elements.at(0); + qreal totalLength = length(); qreal curLen = 0; qreal bezierLen = 0; diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp index 47cd7c6..21ce9e1 100644 --- a/tests/auto/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp @@ -1040,6 +1040,11 @@ void tst_QPainterPath::pointAtPercent_data() QRectF rect(241, 273, 185, 228); path.addEllipse(rect); QTest::newRow("Case 17") << path << qreal(1.0) << QPointF(rect.right(), qreal(0.5) * (rect.top() + rect.bottom())); + + path = QPainterPath(); + path.moveTo(100, 100); + QTest::newRow("Case 18") << path << qreal(0.0) << QPointF(100, 100); + QTest::newRow("Case 19") << path << qreal(1.0) << QPointF(100, 100); } void tst_QPainterPath::pointAtPercent() |