Skip to content

Commit

Permalink
Fix exception when expanding the canvas while pasting
Browse files Browse the repository at this point in the history
Clamp() throws an exception if the max is less than the min value, i.e. if canvas_size.Width - cb_image.Width is negative

Fixes: 2047021
  • Loading branch information
cameronwhite committed Dec 20, 2023
1 parent bfd8ced commit 257ecd7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Pinta/Actions/Edit/PasteAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public static async void Paste (Document doc, bool toNewLayer, PointI pastePosit
// If the pasted image would fall off bottom- or right-
// side of image, adjust paste position
pastePosition = new PointI (
X: Math.Clamp (pastePosition.X, 0, canvas_size.Width - cb_image.Width),
Y: Math.Clamp (pastePosition.Y, 0, canvas_size.Height - cb_image.Height)
X: Math.Clamp (pastePosition.X, 0, Math.Max (0, canvas_size.Width - cb_image.Width)),
Y: Math.Clamp (pastePosition.Y, 0, Math.Max (0, canvas_size.Height - cb_image.Height))
);

// If requested, create a new layer, make it the current
Expand Down

0 comments on commit 257ecd7

Please sign in to comment.