Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Streamline the logic in CutThroughShapeStrategy
Agata Cacko040403dd3482
diff --git a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp b/plugins/tools/tool_knife/CutThroughShapeStrategy.cppindex 23fd2b545c..ef6a3b09a8 100644--- a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp+++ b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp@@ -122,20 +122,30 @@ bool CutThroughShapeStrategy::willShapeBeCutPrecise(const QPainterPath& srcOutli|| KisAlgebra2D::getLineSegmentCrossingLineIndexes(rightLine, srcOutline).count() > 0;- if (!bothGapLinePointsInside && !crossesGapLine) {- bool containsPointWithinGap = false;- Q_FOREACH(QPointF p, srcOutline.toFillPolygon()) {- if (gapLinePolygon.containsPoint(p, Qt::WindingFill)) {- containsPointWithinGap = true;- break;- }- }+ // it doesn't contain exactly one point, therefore it contains either both or none.+ // if it contains both, it will be true.+ // if it contains none:+ // if it crosses either gap line, it will be true+ // if any of the shape points are inside the gap, it will be true+ // otherwise it's false++ if (bothGapLinePointsInside) {+ return true;+ }++ if (crossesGapLine) {+ return true;+ }- if (!containsPointWithinGap) {- return false;+ Q_FOREACH(QPointF p, srcOutline.toFillPolygon()) {+ if (gapLinePolygon.containsPoint(p, Qt::WindingFill)) {+ // a shape point is inside the gap shape+ return true;}}- return true;++ return false;+}void CutThroughShapeStrategy::initializeOutlineObjects(const QTransform &booleanWorkaroundTransform, QList<KoShape *> allShapes, QList<QPainterPath> &outSrcOutlines, QRectF &outOutlineRect)