Browse Source

Fix holding down shift and scaling down the selected area to a single pixel leads to a crash

Equbuxu 2 years ago
parent
commit
5925eba50b

+ 0 - 1
src/PixiEditor.ChangeableDocument/Changes/Selection/SelectionChangeHelper.cs

@@ -13,7 +13,6 @@ internal class SelectionChangeHelper
         var matrix = Matrix3X3.CreateTranslation((float)-originalPathTightBounds.X, (float)-originalPathTightBounds.Y).PostConcat(
             OperationHelper.CreateMatrixFromPoints(to, originalPathTightBounds.Size));
         newPath.Transform(matrix);
-
         var toDispose = target.Selection.SelectionPath;
         target.Selection.SelectionPath = newPath;
         toDispose.Dispose();

+ 11 - 4
src/PixiEditor/Views/UserControls/Overlays/SelectionOverlay.cs

@@ -82,11 +82,18 @@ internal class SelectionOverlay : Control
         if (Path is null)
             return;
 
-        renderPath = new PathGeometry()
+        try
         {
-            FillRule = FillRule.EvenOdd,
-            Figures = (PathFigureCollection?)converter.ConvertFromString(Path.ToSvgPathData()),
-        };
+            renderPath = new PathGeometry()
+            {
+                FillRule = FillRule.EvenOdd,
+                Figures = (PathFigureCollection?)converter.ConvertFromString(Path.ToSvgPathData()),
+            };
+        }
+        catch (FormatException)
+        {
+            return;
+        }
         drawingContext.DrawGeometry(null, whitePen, renderPath);
         drawingContext.DrawGeometry(fillBrush, blackDashedPen, renderPath);
     }