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 subpath deletion failing sometimes

Luna Lovecraft329d8714c652
diff --git a/libs/flake/commands/KoPathPointRemoveCommand.cpp b/libs/flake/commands/KoPathPointRemoveCommand.cpp
index d2b086a8b4..10340d8571 100644
--- a/libs/flake/commands/KoPathPointRemoveCommand.cpp
+++ b/libs/flake/commands/KoPathPointRemoveCommand.cpp
@@ -93,6 +93,12 @@ KUndo2Command *KoPathPointRemoveCommand::createCommand(
if (pointsToDelete.size() > 0) {
new KoPathPointRemoveCommand(pointsToDelete, cmd);
}
+
+ //Reverse sort the subpath list to account for shifting indices of the subpaths
+ std::sort(subpathToDelete.begin(), subpathToDelete.end(), [](KoPathPointData a, KoPathPointData b) {
+ return a.pointIndex > b.pointIndex;
+ });
+
Q_FOREACH (const KoPathPointData & pd, subpathToDelete) {
new KoSubpathRemoveCommand(pd.pathShape, pd.pointIndex.first, cmd);
}