app: store versions of GEGL operations in XCF files.

I broke MR !1660 commits into 2 commits so that the strings are added
now (freeing this up for the upcoming string freeze), with this commit.

A next commit will be needed when we'll have the proper version update
infrastructure on GEGL side, because right now, all we can do when
filter versions don't match is ignoring the filter.
This commit is contained in:
Jehan 2024-08-19 13:21:08 +02:00
parent c7e1b11bed
commit b5a0da63bc
4 changed files with 48 additions and 3 deletions

View File

@ -2938,7 +2938,11 @@ gimp_image_get_xcf_version (GimpImage *image,
{
ADD_REASON (g_strdup_printf (_("Layer effects were added in %s"),
"GIMP 3.0"));
version = MAX (20, version);
/* Version 20 added layer effects; version 22 stored the effect
* version as an additional field. Only ever store as XCF 22
* when layer effects are used.
*/
version = MAX (22, version);
}
}
g_list_free (items);
@ -3113,6 +3117,8 @@ gimp_image_get_xcf_version (GimpImage *image,
case 18:
case 19:
case 20:
case 21:
case 22:
if (gimp_version) *gimp_version = 300;
if (version_string) *version_string = "GIMP 3.0";
break;

View File

@ -99,6 +99,7 @@ typedef struct
gchar *name;
gchar *icon_name;
gchar *operation_name;
gchar *op_version;
GimpChannel *mask;
gboolean is_visible;
gdouble opacity;
@ -2519,8 +2520,12 @@ xcf_load_effect_props (XcfInfo *info,
{
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_WARNING,
"XCF Warning: filter \"%s\" does not "
"have the %s property. It was not set.",
_("XCF Warning: version %s of filter \"%s\" does not "
"have the %s property. The property was ignored and "
"the filter may not render properly.\n"
"This should not happen. "
"You should report the issue to the filter's developers."),
filter->op_version ? filter->op_version : "0:0",
filter->operation_name, filter_prop_name);
valid_prop_value = FALSE;
goto set_or_seek_node_property;
@ -3365,6 +3370,12 @@ xcf_load_effect (XcfInfo *info,
xcf_read_string (info, &string, 1);
filter->operation_name = string;
if (info->file_version >= 22)
{
xcf_read_string (info, &string, 1);
filter->op_version = string;
}
if (! gegl_has_operation (filter->operation_name) ||
! g_strcmp0 (filter->operation_name, "gegl:nop"))
{
@ -3386,6 +3397,24 @@ xcf_load_effect (XcfInfo *info,
return filter;
}
if (filter->op_version &&
g_strcmp0 (gegl_operation_get_op_version (filter->operation_name),
filter->op_version) != 0)
{
filter->unsupported_operation = TRUE;
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_ERROR,
_("XCF Warning: version '%s' of filter '%s' is unsupported. "
"The filter was discarded.\n"
"It either means that you are using an old version of the filter or "
"that it was updated without proper version management. "
"In the latter case, you should report the issue to the filter's developers."),
filter->op_version, filter->operation_name);
return filter;
}
/* We'll set valid properties individually */
filter->operation = gegl_node_new ();
gegl_node_set (filter->operation,
@ -3428,6 +3457,7 @@ xcf_load_free_effect (FilterData *data)
g_free (data->name);
g_free (data->icon_name);
g_free (data->operation_name);
g_free (data->op_version);
g_clear_object (&data->operation);
g_clear_object (&data->mask);
g_free (data);

View File

@ -2131,6 +2131,7 @@ xcf_save_effect (XcfInfo *info,
GimpDrawableFilter *filter_drawable;
GeglNode *node;
gchar *operation;
const gchar *op_version;
GimpChannel *effect_mask;
goffset offset;
GError *tmp_error = NULL;
@ -2159,6 +2160,13 @@ xcf_save_effect (XcfInfo *info,
xcf_write_string_check_error (info, (gchar **) &operation, 1, ;);
g_free (operation);
if (info->file_version >= 22)
{
/* Write out GEGL operation version */
op_version = gegl_operation_get_op_version (operation);
xcf_write_string_check_error (info, (gchar **) &op_version, 1, ;);
}
/* write out the effect properties */
xcf_save_effect_props (info, image, filter, error);

View File

@ -90,6 +90,7 @@ static GimpXcfLoaderFunc * const xcf_loaders[] =
xcf_load_image, /* version 19 */
xcf_load_image, /* version 20 */
xcf_load_image, /* version 21 */
xcf_load_image, /* version 22 */
};