From 697910e5fbd382e78bc1bcbac3f5824aded059b4 Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 28 Jun 2019 14:40:04 +0200 Subject: Fix assert in QPainterPath after clear() The newly introduced clear() method left the path in an undefined state: d_ptr allocated, but no elements. The elements vector is otherwise never empty, since ensureData() inserts a dummy initial moveTo element. Fix by making sure that clear() leaves the path in the same state as ensureData() (i.e. "empty" but not "null"), except possibly more capacity allocated in the elements vector. Fixes: QTBUG-76534 Change-Id: I7ad8b312913f5eb6e22023f5d2fd873e54b1e23c Reviewed-by: Allan Sandfeld Jensen --- tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'tests/auto/gui/painting') diff --git a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp index c90348e91a..67cf9a321a 100644 --- a/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp +++ b/tests/auto/gui/painting/qpainterpath/tst_qpainterpath.cpp @@ -161,10 +161,18 @@ void tst_QPainterPath::clear() p1.clear(); QCOMPARE(p1, p2); + p1.lineTo(50, 50); + QPainterPath p3; + QCOMPARE(p1.elementCount(), 2); + p3.lineTo(50, 50); + QCOMPARE(p1, p3); + QCOMPARE(p1.fillRule(), Qt::OddEvenFill); p1.setFillRule(Qt::WindingFill); + QVERIFY(p1 != p3); p1.clear(); - QCOMPARE(p1.fillRule(), Qt::WindingFill); + QCOMPARE(p1.fillRule(), Qt::OddEvenFill); + QCOMPARE(p1, p2); } void tst_QPainterPath::reserveAndCapacity() -- cgit v1.2.3