From 7fd7454805ea091688339111e544cb70f7a24739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Tue, 25 Jan 2011 11:02:16 +0100 Subject: Fixed QPainterPath::pointAtPercent(t) for one-element paths. Return the MoveTo element instead of QPointF(0, 0). Task-number: QTBUG-16788 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/painting/qpainterpath.cpp | 5 ++++- tests/auto/qpainterpath/tst_qpainterpath.cpp | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index 7d6ea12..1b69234 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -2894,9 +2894,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 19b3156..ad5a968 100644 --- a/tests/auto/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp @@ -1041,6 +1041,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() -- cgit v0.12 From 78a7a02b3b85435bc28eb23e9210522467171e42 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Wed, 26 Jan 2011 15:17:44 +0100 Subject: Fixed a stupid typo --- examples/scroller/plot/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/scroller/plot/main.cpp b/examples/scroller/plot/main.cpp index 6166505..1e7db64 100644 --- a/examples/scroller/plot/main.cpp +++ b/examples/scroller/plot/main.cpp @@ -214,7 +214,7 @@ int main(int argc, char **argv) else mw.show(); #if defined(Q_WS_MAC) - mw->raise(); + mw.raise(); #endif return a.exec(); } -- cgit v0.12