Fix regression: line tool draws extra pixels on the canvas edge

How the bug could be reproduced (before this fix):
- Select the line tool.
- Click and hold down the left mouse button on the canvas to put the first line point.
- Drag the mouse outside the canvas and move it around (like trying to put the second point of the line outside the canvas).
This commit is contained in:
Gaspar Capello 2021-04-21 09:24:59 -03:00 committed by David Capello
parent 63ec1f2ae8
commit 4d9d1f309c

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2020-2021 Igara Studio S.A.
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
@ -81,11 +81,11 @@ void PointShape::doInkHline(int x1, int y, int x2, ToolLoop* loop)
}
// Clipped in X axis
else {
x1 = base::clamp(x1, 0, dstw-1);
x2 = base::clamp(x2, 0, dstw-1);
if (x2-x1+1 < 1)
if (x2 < 0 || x1 >= dstw || x2-x1+1 < 1)
return;
x1 = base::clamp(x1, 0, dstw-1);
x2 = base::clamp(x2, 0, dstw-1);
ink->inkHline(x1, y, x2, loop);
}
}