Skip to content

armgit / krita

Public Imported from GitHub
0

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++

Fix Knife Tool inaction for perfect mouse lines

Agata Cacko44769d249a44
diff --git a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
index d1c8c1a810..97b0468bd6 100644
--- a/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
+++ b/plugins/tools/tool_knife/CutThroughShapeStrategy.cpp
@@ -176,8 +176,10 @@ void CutThroughShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
QTransform booleanWorkaroundTransformInverted = booleanWorkaroundTransform.inverted();
- QRectF gapLineLeftRect = KisAlgebra2D::createRectFromCorners(leftLine);
+ QRectF gapLineLeftRect = KisAlgebra2D::createRectFromCorners(leftLine); // warning! can be empty for perfectly horizontal/vertical lines
QRectF gapLineRightRect = KisAlgebra2D::createRectFromCorners(rightLine);
+ QRectF gapLineRect = gapLineLeftRect | gapLineRightRect; // will not be empty if the gutterWidth > 0
+ bool checkGapLineRect = !gapLineRect.isEmpty();
for (int i = 0; i < srcOutlines.size(); i++) {
@@ -206,9 +208,9 @@ void CutThroughShapeStrategy::finishInteraction(Qt::KeyboardModifiers modifiers)
continue;
}
- if ((srcOutlines[i].boundingRect() & gapLineLeftRect).isEmpty()
- || (srcOutlines[i].boundingRect() & gapLineRightRect).isEmpty()) {
- // the gap lines can't cross the shape since their bounding rects don't cross
+
+ if (checkGapLineRect && (srcOutlines[i].boundingRect() & gapLineRect).isEmpty()) {
+ // the gap lines can't cross the shape since their bounding rects don't cross it
if (wasSelected) {
newSelectedShapes << referenceShape;
}