From 498042b66c328d415ceaddaffbec4238aaae062d Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Tue, 6 Aug 2024 17:30:16 +0000 Subject: [PATCH] tools, xcf: Don't load gegl:nop filters In earlier development, we accidentally allowed users to save gegl:nop filters. Since they are valid operations, they were not triggering our unsupported operations delete code. This patch adds a second check to see if the operation is a nop, and deletes it as well. This patch also adds a check to make sure a filter is in the filter stack before reordering it. This was revealed by the nop bug, so it makes sense to patch both at once. --- app/tools/gimpfiltertool.c | 11 +++++++++-- app/xcf/xcf-load.c | 26 +++++++++++++++++--------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c index a9a44beea31..8cbf7ed7199 100644 --- a/app/tools/gimpfiltertool.c +++ b/app/tools/gimpfiltertool.c @@ -1949,11 +1949,18 @@ gimp_filter_tool_set_config (GimpFilterTool *filter_tool, mask = gimp_drawable_filter_get_mask (filter_tool->existing_filter); if (filters) { + gint existing_index; + index = gimp_container_get_child_index (filters, GIMP_OBJECT (filter_tool->existing_filter)); - gimp_container_reorder (filters, GIMP_OBJECT (filter_tool->filter), - index); + existing_index = + gimp_container_get_child_index (filters, + GIMP_OBJECT (filter_tool->filter)); + + if (existing_index > -1) + gimp_container_reorder (filters, GIMP_OBJECT (filter_tool->filter), + index); } g_object_set (filter_tool->filter, diff --git a/app/xcf/xcf-load.c b/app/xcf/xcf-load.c index 2057c329985..11adecdad5b 100644 --- a/app/xcf/xcf-load.c +++ b/app/xcf/xcf-load.c @@ -1079,13 +1079,13 @@ xcf_load_add_effects (XcfInfo *info, { FilterData *data = iter->data; - if (! data->icon_name) - data->icon_name = g_strdup ("gimp-gegl"); - if (! data->unsupported_operation) { GimpDrawableFilter *filter = NULL; + if (! data->icon_name) + data->icon_name = g_strdup ("gimp-gegl"); + filter = gimp_drawable_filter_new (GIMP_DRAWABLE (layer), data->name, data->operation, data->icon_name); @@ -3365,15 +3365,23 @@ xcf_load_effect (XcfInfo *info, xcf_read_string (info, &string, 1); filter->operation_name = string; - if (! gegl_has_operation (filter->operation_name)) + if (! gegl_has_operation (filter->operation_name) || + ! g_strcmp0 (filter->operation_name, "gegl:nop")) { filter->unsupported_operation = TRUE; - gimp_message (info->gimp, G_OBJECT (info->progress), - GIMP_MESSAGE_WARNING, - "XCF Warning: the \"%s\" (%s) filter is " - "not installed. It was discarded.", - filter->name, filter->operation_name); + if (! g_strcmp0 (filter->operation_name, "gegl:nop")) + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, + "XCF Warning: A filter was saved as a " + "gegl:nop. This should not happen. Please " + "report this to the developers."); + else + gimp_message (info->gimp, G_OBJECT (info->progress), + GIMP_MESSAGE_WARNING, + "XCF Warning: the \"%s\" (%s) filter is " + "not installed. It was discarded.", + filter->name, filter->operation_name); return filter; } -- GitLab