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++
Make vector and raster selections to behave in the same way when creating tiny selections
Dmitry Kazakovc3279cd2ae46
diff --git a/libs/ui/tool/kis_selection_tool_helper.cpp b/libs/ui/tool/kis_selection_tool_helper.cppindex 9bdfb3cc74..71aa171103 100644--- a/libs/ui/tool/kis_selection_tool_helper.cpp+++ b/libs/ui/tool/kis_selection_tool_helper.cpp@@ -218,18 +218,26 @@ void KisSelectionToolHelper::addSelectionShapes(QList< KoShape* > shapes, SelectKUndo2Command* paint() override {KUndo2Command *resultCommand = 0;-KisSelectionSP selection = m_view->selection();if (selection) {KisShapeSelection * shapeSelection = static_cast<KisShapeSelection*>(selection->shapeSelection());- if (shapeSelection) {- QList<KoShape*> existingShapes = shapeSelection->shapes();+ if (shapeSelection ||+ m_action == SELECTION_SUBTRACT) {QPainterPath path1;- path1.setFillRule(Qt::WindingFill);- Q_FOREACH(KoShape *shape, existingShapes) {- path1 += shape->absoluteTransformation().map(shape->outline());+ QList<KoShape*> existingShapes;++ if (shapeSelection) {+ existingShapes = shapeSelection->shapes();++ path1.setFillRule(Qt::WindingFill);+ Q_FOREACH(KoShape *shape, existingShapes) {+ path1 += shape->absoluteTransformation().map(shape->outline());+ }+ } else if (m_action == SELECTION_SUBTRACT) {+ KisImageSP image = m_view->image();+ path1.addRect(m_view->viewConverter()->imageRectInDocumentPixels());}QPainterPath path2;@@ -275,7 +283,9 @@ void KisSelectionToolHelper::addSelectionShapes(QList< KoShape* > shapes, SelectKUndo2Command *parentCommand = new KUndo2Command();- m_view->canvasBase()->shapeController()->removeShapes(existingShapes, parentCommand);+ if (!existingShapes.isEmpty()) {+ m_view->canvasBase()->shapeController()->removeShapes(existingShapes, parentCommand);+ }m_view->canvasBase()->shapeController()->addShape(newShape, 0, parentCommand);if (path.isEmpty()) {@@ -286,10 +296,12 @@ void KisSelectionToolHelper::addSelectionShapes(QList< KoShape* > shapes, Select}resultCommand = parentCommand;+ } else if (m_action == SELECTION_INTERSECT) {+ // just do nothing if there is nothing to intersect with+ return nullptr;}}-if (!resultCommand) {/*** Mark the shapes that they belong to a shape selectiondiff --git a/plugins/tools/selectiontools/kis_tool_select_elliptical.cc b/plugins/tools/selectiontools/kis_tool_select_elliptical.ccindex ac2101836a..50674d2dfe 100644--- a/plugins/tools/selectiontools/kis_tool_select_elliptical.cc+++ b/plugins/tools/selectiontools/kis_tool_select_elliptical.cc@@ -51,6 +51,10 @@ void KisToolSelectElliptical::finishRect(const QRectF &rect, qreal roundCornersXreturn;}+ if (rect.isEmpty()) {+ return;+ }+const SelectionMode mode =helper.tryOverrideSelectionMode(kisCanvas->viewManager()->selection(),selectionMode(),diff --git a/plugins/tools/selectiontools/kis_tool_select_rectangular.cc b/plugins/tools/selectiontools/kis_tool_select_rectangular.ccindex cdffd8e1a0..5550f3f941 100644--- a/plugins/tools/selectiontools/kis_tool_select_rectangular.cc+++ b/plugins/tools/selectiontools/kis_tool_select_rectangular.cc@@ -61,10 +61,10 @@ void KisToolSelectRectangular::finishRect(const QRectF& rect, qreal roundCornersselectionMode(),selectionAction());+ if (!rc.isValid()) {+ return;+ }if (mode == PIXEL_SELECTION) {- if (!rc.isValid()) {- return;- }KisProcessingApplicator applicator(currentImage(),currentNode(),KisProcessingApplicator::NONE,