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 remove shape from flow action

Dmitry Kazakov3aa64a5dc95e
diff --git a/libs/flake/commands/KoSvgTextAddRemoveShapeCommands.cpp b/libs/flake/commands/KoSvgTextAddRemoveShapeCommands.cpp
index c9881d9e27..e92dfc3764 100644
--- a/libs/flake/commands/KoSvgTextAddRemoveShapeCommands.cpp
+++ b/libs/flake/commands/KoSvgTextAddRemoveShapeCommands.cpp
@@ -33,14 +33,6 @@ KoSvgTextAddRemoveShapeCommandImpl::KoSvgTextAddRemoveShapeCommandImpl(KoSvgText
: KisCommandUtils::FlipFlopCommand(state, parent)
, d(new Private(textShape, shape))
{
- /**
- * 1) The shapes should belong to the same parent or have no parent at all.
- * 2) The parent of the text shape is always preserved (null or non-null)
- * 3) The parent of the contour shape is dropped, since it is put into
- * a virtual group created by the text shape
- */
- KIS_SAFE_ASSERT_RECOVER_NOOP(!textShape->parent() || !shape->parent() || textShape->parent() == shape->parent());
-
d->removeCommand = state == FINALIZING;
if (!d->removeCommand) {
@@ -128,7 +120,13 @@ void KoSvgTextAddRemoveShapeCommandImpl::partA()
KoSvgTextAddShapeCommand::KoSvgTextAddShapeCommand(KoSvgTextShape *textShape, KoShape *shape, bool inside, KUndo2Command *parentCommand)
: KoSvgTextAddRemoveShapeCommandImpl(textShape, shape, (inside? Inside: Subtract), INITIALIZING, parentCommand)
{
-
+ /**
+ * 1) The shapes should belong to the same parent or have no parent at all.
+ * 2) The parent of the text shape is always preserved (null or non-null)
+ * 3) The parent of the contour shape is dropped, since it is put into
+ * a virtual group created by the text shape
+ */
+ KIS_SAFE_ASSERT_RECOVER_NOOP(!textShape->parent() || !shape->parent() || textShape->parent() == shape->parent());
}
KoSvgTextAddShapeCommand::~KoSvgTextAddShapeCommand()
@@ -140,6 +138,7 @@ KoSvgTextRemoveShapeCommand::KoSvgTextRemoveShapeCommand(KoSvgTextShape *textSha
: KoSvgTextAddRemoveShapeCommandImpl(textShape, shape, Unknown, FINALIZING, parentCommand)
{
// the \p shape will be ungrouped into the parent of \p textShape
+ KIS_SAFE_ASSERT_RECOVER_NOOP(textShape->shapeInContours(shape));
}
KoSvgTextRemoveShapeCommand::~KoSvgTextRemoveShapeCommand()
diff --git a/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp b/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
index 212c3a2eeb..a3dd37a018 100644
--- a/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
+++ b/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
@@ -583,9 +583,6 @@ void DefaultTool::slotAddShapesToFlow()
new KoKeepShapesSelectedCommand(selectedShapes, {}, canvas()->selectedShapesProxy(), false, parentCommand);
Q_FOREACH(KoShape *shape, shapes) {
- if(shape->parent()) {
- canvas()->shapeController()->removeShape(shape, parentCommand);
- }
new KoSvgTextAddShapeCommand(textShape, shape, true, parentCommand);
}
new KoKeepShapesSelectedCommand({}, {textShape}, canvas()->selectedShapesProxy(), true, parentCommand);
@@ -621,9 +618,6 @@ void DefaultTool::slotSubtractShapesFromFlow()
new KoKeepShapesSelectedCommand(selectedShapes, {}, canvas()->selectedShapesProxy(), false, parentCommand);
Q_FOREACH(KoShape *shape, shapes) {
- if (shape->parent()) {
- canvas()->shapeController()->removeShape(shape, parentCommand);
- }
new KoSvgTextAddShapeCommand(textShape, shape, false, parentCommand);
}
new KoKeepShapesSelectedCommand({}, {textShape}, canvas()->selectedShapesProxy(), true, parentCommand);
@@ -649,8 +643,9 @@ void DefaultTool::slotRemoveShapesFromFlow()
Q_FOREACH(KoShape *shape, selectedShapes) {
if (!textShape->shapeInContours(shape)) continue;
new KoSvgTextRemoveShapeCommand(textShape, shape, parentCommand);
- canvas()->shapeController()->addShape(shape, textShape->parent(), parentCommand);
}
+ new KoKeepShapesSelectedCommand({}, {selectedShapes}, canvas()->selectedShapesProxy(), true, parentCommand);
+
canvas()->addCommand(parentCommand);
}