diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 3326bd399..a99b55de3 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -1438,17 +1438,37 @@ bool VAbstractPiece::IsAllowanceValid(const QVector &base, const QVecto return false; // Wrong direction } - for (auto i = 0; i < base.count()-1; ++i) + for (auto i = 0; i < base.count(); ++i) { - QLineF baseSegment(base.at(i), base.at(i+1)); + int nextI = -1; + if (i < base.count()-1) + { + nextI = i + 1; + } + else + { + nextI = 0; + } + + QLineF baseSegment(base.at(i), base.at(nextI)); if (baseSegment.isNull()) { continue; } - for (auto j = 0; j < allowance.count()-1; ++j) + for (auto j = 0; j < allowance.count(); ++j) { - QLineF allowanceSegment(allowance.at(j), allowance.at(j+1)); + int nextJ = -1; + if (j < allowance.count()-1) + { + nextJ = j + 1; + } + else + { + nextJ = 0; + } + + QLineF allowanceSegment(allowance.at(j), allowance.at(nextJ)); if (allowanceSegment.isNull()) { continue; @@ -1462,7 +1482,6 @@ bool VAbstractPiece::IsAllowanceValid(const QVector &base, const QVecto && not VGObject::IsPointOnLineviaPDP(allowanceSegment.p1(), baseSegment.p1(), baseSegment.p2()) && not VGObject::IsPointOnLineviaPDP(allowanceSegment.p2(), baseSegment.p1(), baseSegment.p2())) { - return false; } }