From ae71d2b70e491cc5bac4023ca0243cf7d8c7c300 Mon Sep 17 00:00:00 2001 From: Mateusz Krajewski Date: Fri, 14 Jan 2022 18:51:33 +0000 Subject: [PATCH] PixelPaint: Restrict "crop to selection" to image boundaries --- Userland/Applications/PixelPaint/MainWidget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index 67b1c00d08..2eba69e9fe 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace PixelPaint { @@ -467,7 +468,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) // FIXME: disable this action if there is no selection if (editor->selection().is_empty()) return; - auto crop_rect = editor->selection().bounding_rect(); + auto crop_rect = editor->image().rect().intersected(editor->selection().bounding_rect()); editor->image().crop(crop_rect); editor->selection().clear(); }));