1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:07:45 +00:00

PixelPaint: Ensure bitmap contains selected pixel before deleting

This fixes a bug which shows up when a layer is offset and the selection
range includes pixels that are outside the current layer bitmap rect. We
would still try to delete that pixel from the bitmap since there was no
contains() check.
This commit is contained in:
Timothy Slater 2022-09-02 15:27:05 -05:00 committed by Linus Groh
parent 53e4cc16ff
commit 7b163573e6

View file

@ -142,7 +142,7 @@ void Layer::erase_selection(Selection const& selection)
for (int x = translated_to_layer_space.left(); x < translated_to_layer_space.left() + translated_to_layer_space.width(); ++x) { for (int x = translated_to_layer_space.left(); x < translated_to_layer_space.left() + translated_to_layer_space.width(); ++x) {
// Selection is still in pre-translated coordinates, account for this by adding the layer's relative location // Selection is still in pre-translated coordinates, account for this by adding the layer's relative location
if (selection.is_selected(x + location().x(), y + location().y())) { if (content_bitmap().rect().contains(x, y) && selection.is_selected(x + location().x(), y + location().y())) {
content_bitmap().set_pixel(x, y, Color::Transparent); content_bitmap().set_pixel(x, y, Color::Transparent);
} }
} }