From 0dd7d9a936b303d24afb0f079940606d0f2d5fbf Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Fri, 7 Nov 2025 23:10:20 +0000 Subject: [PATCH] actions: Fix "Delete Path" behavior for vector layers Instead of deleting all selected paths except for those attached to vector layers, we stop the action and notify the user that they can not delete paths attached to vector layers. --- app/actions/paths-commands.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/app/actions/paths-commands.c b/app/actions/paths-commands.c index c11aa11de6..32ed388bf3 100644 --- a/app/actions/paths-commands.c +++ b/app/actions/paths-commands.c @@ -49,6 +49,8 @@ #include "path/gimppath-import.h" #include "path/gimpvectorlayer.h" +#include "tools/gimptools-utils.h" + #include "widgets/gimpaction.h" #include "widgets/gimpclipboard.h" #include "widgets/gimphelp-ids.h" @@ -470,31 +472,38 @@ paths_delete_cmd_callback (GimpAction *action, { GimpImage *image; GList *paths; - gboolean attached_to_vector_layer = FALSE; + GtkWidget *widget; return_if_no_paths (image, paths, data); + return_if_no_widget (widget, data); paths = g_list_copy (paths); + + /* Initial check to make sure none are connected to vector layers */ + for (GList *iter = paths; iter; iter = iter->next) + { + if (gimp_path_attached_to_vector_layer (GIMP_PATH (iter->data), image)) + { + gimp_message_literal (image->gimp, G_OBJECT (widget), + GIMP_MESSAGE_WARNING, + _("Cannot delete paths attached to vector " + "layers")); + gimp_tools_blink_item (image->gimp, GIMP_ITEM (iter->data)); + g_list_free (paths); + return; + } + } + /* TODO: proper undo group. */ gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_PATHS_IMPORT, _("Remove Paths")); for (GList *iter = paths; iter; iter = iter->next) - { - /* Verify path is not attached to vector layer */ - if (! gimp_path_attached_to_vector_layer (GIMP_PATH (iter->data), image)) - gimp_image_remove_path (image, iter->data, TRUE, NULL); - else - attached_to_vector_layer = TRUE; - } + gimp_image_remove_path (image, iter->data, TRUE, NULL); gimp_image_undo_group_end (image); gimp_image_flush (image); g_list_free (paths); - - if (attached_to_vector_layer) - gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING, - _("Paths attached to vector layers weren't deleted")); } void