diff --git a/src/libs/vlayout/vabstractdetail.cpp b/src/libs/vlayout/vabstractdetail.cpp index 098882f18..6419c4c77 100644 --- a/src/libs/vlayout/vabstractdetail.cpp +++ b/src/libs/vlayout/vabstractdetail.cpp @@ -338,7 +338,11 @@ QVector VAbstractDetail::CheckLoops(const QVector &points) intersect = line1.intersect(line2, &crosPoint); if (intersect == QLineF::BoundedIntersection && not (i == 0 && j+1 == count-1 && closed)) { // Break, but not if intersects the first edge and the last edge in closed path - break; + if (line1.p1() != crosPoint && line1.p2() != crosPoint && + line2.p1() != crosPoint && line2.p2() != crosPoint) + { + break; + } } intersect = QLineF::NoIntersection; } diff --git a/src/test/ValentinaTest/tst_vabstractdetail.cpp b/src/test/ValentinaTest/tst_vabstractdetail.cpp index dbb2316c0..204ae3ad6 100644 --- a/src/test/ValentinaTest/tst_vabstractdetail.cpp +++ b/src/test/ValentinaTest/tst_vabstractdetail.cpp @@ -172,6 +172,33 @@ void TST_VAbstractDetail::PathRemoveLoop_data() const path.removeLast(); res.removeLast(); QTest::newRow("One loop, the second loop, unclosed a path (six unique points)") << path << res; + + path.clear(); + path << QPointF(20, 10); + path << QPointF(10, 10); + path << QPointF(20, 15); + path << QPointF(10, 20); + path << QPointF(20, 20); + path << QPointF(20, 10); + QTest::newRow("Correct closed a path, point on line (four unique points)") << path << path; + + path.removeLast(); + QTest::newRow("Corect unclosed a path, point on line (four unique points)") << path << path; + + path.clear(); + path << QPointF(20, 10); + path << QPointF(10, 10); + path << QPointF(0, 10); + path << QPointF(10, 15); + path << QPointF(0, 20); + path << QPointF(10, 20); + path << QPointF(20, 20); + path << QPointF(10, 15); + path << QPointF(20, 10); + QTest::newRow("Correct closed a path, point on line (six unique points)") << path << path; + + path.removeLast(); + QTest::newRow("Corect unclosed a path, point on line (six unique points)") << path << path; } //---------------------------------------------------------------------------------------------------------------------