summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/painting/qpainterpath.cpp3
-rw-r--r--tests/auto/qpainterpath/tst_qpainterpath.cpp26
2 files changed, 28 insertions, 1 deletions
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index ffd0d5c..94e2cd4 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1196,7 +1196,8 @@ void QPainterPath::connectPath(const QPainterPath &other)
int first = d->elements.size();
d->elements += other.d_func()->elements;
- d->elements[first].type = LineToElement;
+ if (first != 0)
+ d->elements[first].type = LineToElement;
// avoid duplicate points
if (first > 0 && QPointF(d->elements[first]) == QPointF(d->elements[first - 1])) {
diff --git a/tests/auto/qpainterpath/tst_qpainterpath.cpp b/tests/auto/qpainterpath/tst_qpainterpath.cpp
index d0cddda..66e6d10 100644
--- a/tests/auto/qpainterpath/tst_qpainterpath.cpp
+++ b/tests/auto/qpainterpath/tst_qpainterpath.cpp
@@ -107,6 +107,7 @@ private slots:
void operators();
void connectPathDuplicatePoint();
+ void connectPathMoveTo();
void translate();
};
@@ -1169,6 +1170,31 @@ void tst_QPainterPath::connectPathDuplicatePoint()
QCOMPARE(c, a);
}
+void tst_QPainterPath::connectPathMoveTo()
+{
+ QPainterPath path1;
+ QPainterPath path2;
+ QPainterPath path3;
+ QPainterPath path4;
+
+ path1.moveTo(1,1);
+
+ path2.moveTo(4,4);
+ path2.lineTo(5,6);
+ path2.lineTo(6,7);
+
+ path3.connectPath(path2);
+
+ path4.lineTo(5,5);
+
+ path1.connectPath(path2);
+
+ QVERIFY(path1.elementAt(0).type == QPainterPath::MoveToElement);
+ QVERIFY(path2.elementAt(0).type == QPainterPath::MoveToElement);
+ QVERIFY(path3.elementAt(0).type == QPainterPath::MoveToElement);
+ QVERIFY(path4.elementAt(0).type == QPainterPath::MoveToElement);
+}
+
void tst_QPainterPath::translate()
{
QPainterPath path;