From 540fe925f128a4fde8a5ff372a97efa093051e89 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sun, 7 Dec 2025 17:38:08 +0000 Subject: [PATCH] tools: Crop Tool is conditionally destructive Resolves #15418 Destructive tools can not be used on non-raster layers (vector, text, link). However, the Crop Tool is only destructive when "Delete Pixels" option is enabled - otherwise it just crops the canvas size. This patch toggles the GimpTool classes' "is_destructive" setting based on the value of "Delete Pixels". --- app/tools/gimpcroptool.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c index 9cfb06bca0..6f4225d022 100644 --- a/app/tools/gimpcroptool.c +++ b/app/tools/gimpcroptool.c @@ -165,7 +165,9 @@ gimp_crop_tool_init (GimpCropTool *crop_tool) static void gimp_crop_tool_constructed (GObject *object) { - GimpCropTool *crop_tool = GIMP_CROP_TOOL (object); + GimpTool *tool = GIMP_TOOL (object); + GimpCropTool *crop_tool = GIMP_CROP_TOOL (tool); + GimpCropOptions *options = GIMP_CROP_TOOL_GET_OPTIONS (crop_tool); GimpContext *context; GimpToolInfo *tool_info; @@ -186,6 +188,9 @@ gimp_crop_tool_constructed (GObject *object) gimp_crop_tool_image_changed (crop_tool, gimp_context_get_image (context), context); + + /* The Crop Tool is only destructive when "Delete Pixels" is enabled */ + GIMP_TOOL_GET_CLASS (tool)->is_destructive = options->delete_pixels; } static void @@ -302,7 +307,8 @@ gimp_crop_tool_options_notify (GimpTool *tool, GimpToolOptions *options, const GParamSpec *pspec) { - GimpCropTool *crop_tool = GIMP_CROP_TOOL (tool); + GimpCropTool *crop_tool = GIMP_CROP_TOOL (tool); + GimpCropOptions *crop_options = GIMP_CROP_TOOL_GET_OPTIONS (crop_tool); if (! strcmp (pspec->name, "layer-only") || ! strcmp (pspec->name, "allow-growing")) @@ -317,6 +323,10 @@ gimp_crop_tool_options_notify (GimpTool *tool, gimp_crop_tool_update_option_defaults (crop_tool, FALSE); } } + else if (! strcmp (pspec->name, "delete-pixels")) + { + GIMP_TOOL_GET_CLASS (tool)->is_destructive = crop_options->delete_pixels; + } } static void