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 deadlock when doing perspective transform

Luna Lovecraft7eaaef7ba568
diff --git a/plugins/tools/tool_transform2/kis_perspective_transform_strategy.cpp b/plugins/tools/tool_transform2/kis_perspective_transform_strategy.cpp
index f60145dee6..94c901f90a 100644
--- a/plugins/tools/tool_transform2/kis_perspective_transform_strategy.cpp
+++ b/plugins/tools/tool_transform2/kis_perspective_transform_strategy.cpp
@@ -523,6 +523,17 @@ void KisPerspectiveTransformStrategy::continuePrimaryAction(const QPointF &mouse
Eigen::Matrix3f B = getTransitionMatrix(m_d->dstHandlePoints);
Eigen::Matrix3f result = B * A.inverse();
+ // Points in dstHandlePoints are not arranged in an organized way, so if we used it directly as a polygon it
+ // will never be considered convex
+ QPolygonF poly;
+ poly << m_d->dstHandlePoints[HANDLE_TOP_LEFT] << m_d->dstHandlePoints[HANDLE_TOP_RIGHT]
+ << m_d->dstHandlePoints[HANDLE_BOTTOM_RIGHT] << m_d->dstHandlePoints[HANDLE_BOTTOM_LEFT];
+
+ //Don't apply the handle movement if it makes the transform area not convex
+ if (!KisAlgebra2D::isPolygonTrulyConvex(poly)) {
+ break;
+ }
+
m_d->transformIntoArgs(result);
break;