1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 01:12:40 +02:00

tools: Don't commit Filter Tool without a filter

The Filter Tool is a "hidden" tool that we switch to
when applying a filter. Like other tools, it commits when
we save our image. However, we may no longer have an
active filter in the tool when we do so (like, after applying
an NDE filter). Because we check the drawable from the
filter to confirm whether we should force NDE or not,
this can cause a CRITICAL when we try to access a now
non-existent filter.

This patch extends the "if (filter_tool->filter)" check to
cover the full commit check process, to prevent the bug.
This commit is contained in:
Alx Sa
2025-10-02 12:07:25 +00:00
parent 67fa72a94e
commit 81c67e5614

View File

@@ -562,48 +562,50 @@ gimp_filter_tool_control (GimpTool *tool,
case GIMP_TOOL_ACTION_COMMIT:
if (filter_tool->filter)
drawable = gimp_drawable_filter_get_drawable (filter_tool->filter);
/* TODO: Expand non-destructive editing to other drawables
* besides layers and channels */
if ((! GIMP_IS_LAYER (drawable) && ! GIMP_IS_CHANNEL (drawable)) ||
GIMP_IS_LAYER_MASK (drawable) ||
(! filter_tool->existing_filter && options->merge_filter))
non_destructive = FALSE;
if (filter_tool->operation)
{
gegl_node_get (filter_tool->operation,
"operation", &operation_name,
NULL);
drawable = gimp_drawable_filter_get_drawable (filter_tool->filter);
if (! g_strcmp0 (operation_name, "gegl:nop"))
/* TODO: Expand non-destructive editing to other drawables
* besides layers and channels */
if ((! GIMP_IS_LAYER (drawable) && ! GIMP_IS_CHANNEL (drawable)) ||
GIMP_IS_LAYER_MASK (drawable) ||
(! filter_tool->existing_filter && options->merge_filter))
non_destructive = FALSE;
/* TODO: Once we can serialize GimpDrawable, remove so that filters with
* aux nodes can be non-destructive */
if (gegl_node_has_pad (filter_tool->operation, "aux") ||
/* GEGL graph is dangerous even without using third-party
* effects, because it may run any effect. E.g. it can
* run sink effects overwriting any local files with user
* rights. We leave a way in through an environment
* variable because it is a useful tool for GEGL ops
* developers but it should only be set while knowing what
* you are doing.
*/
(g_strcmp0 (operation_name, "gegl:gegl") == 0 &&
g_getenv ("GIMP_ALLOW_GEGL_GRAPH_LAYER_EFFECT") == NULL))
non_destructive = FALSE;
if (filter_tool->operation)
{
gegl_node_get (filter_tool->operation,
"operation", &operation_name,
NULL);
g_free (operation_name);
if (! g_strcmp0 (operation_name, "gegl:nop"))
non_destructive = FALSE;
/* TODO: Once we can serialize GimpDrawable, remove so that
* filters with aux nodes can be non-destructive */
if (gegl_node_has_pad (filter_tool->operation, "aux") ||
/* GEGL graph is dangerous even without using third-party
* effects, because it may run any effect. E.g. it can
* run sink effects overwriting any local files with user
* rights. We leave a way in through an environment
* variable because it is a useful tool for GEGL ops
* developers but it should only be set while knowing what
* you are doing.
*/
(g_strcmp0 (operation_name, "gegl:gegl") == 0 &&
g_getenv ("GIMP_ALLOW_GEGL_GRAPH_LAYER_EFFECT") == NULL))
non_destructive = FALSE;
g_free (operation_name);
}
/* Ensure that filters applied to group, vector or link layers are
* non-destructive */
if (GIMP_IS_GROUP_LAYER (drawable) ||
gimp_item_is_vector_layer (GIMP_ITEM (drawable)) ||
gimp_item_is_link_layer (GIMP_ITEM (drawable)))
non_destructive = TRUE;
}
/* Ensure that filters applied to group, vector or link layers are non-destructive */
if (GIMP_IS_GROUP_LAYER (drawable) ||
gimp_item_is_vector_layer (GIMP_ITEM (drawable)) ||
gimp_item_is_link_layer (GIMP_ITEM (drawable)))
non_destructive = TRUE;
gimp_filter_tool_commit (filter_tool, non_destructive);
break;
}