plug-ins: fix #6258 Hierarchical XMP tag should be written to Array

When saving XMP metadata were using gexiv2_metadata_get_tag_string for all
tags, even those that can have multiple values. This caused those values
to be saved as one value instead of multiple.

To fix this we use gexiv2_metadata_get_tag_multiple, except for XmpText.
Then we add all returned values for that tag separately to our metadata.

(cherry picked from commit af888e481f)
This commit is contained in:
Jacob Boerema
2021-09-24 13:42:45 -04:00
parent d4efd7005d
commit aed3d9c779

View File

@ -822,6 +822,11 @@ gimp_metadata_serialize (GimpMetadata *metadata)
if (xmp_data) if (xmp_data)
{ {
for (i = 0; xmp_data[i] != NULL; i++) for (i = 0; xmp_data[i] != NULL; i++)
{
/* XmpText is always a single value, but structures like
* XmpBag and XmpSeq can have multiple values that need to be
* treated separately or else saving will do things wrong. */
if (! g_strcmp0 (gexiv2_metadata_get_tag_type (xmp_data[i]), "XmpText"))
{ {
value = gexiv2_metadata_get_tag_string (GEXIV2_METADATA (metadata), value = gexiv2_metadata_get_tag_string (GEXIV2_METADATA (metadata),
xmp_data[i]); xmp_data[i]);
@ -830,7 +835,27 @@ gimp_metadata_serialize (GimpMetadata *metadata)
gimp_metadata_append_tag (string, xmp_data[i], escaped, base64); gimp_metadata_append_tag (string, xmp_data[i], escaped, base64);
} }
else
{
gchar **values;
values = gexiv2_metadata_get_tag_multiple (GEXIV2_METADATA (metadata),
xmp_data[i]);
if (values)
{
gint vi;
for (vi = 0; values[vi] != NULL; vi++)
{
escaped = gimp_metadata_escape (xmp_data[i], values[vi], &base64);
gimp_metadata_append_tag (string, xmp_data[i], escaped, base64);
}
g_strfreev (values);
}
}
}
g_strfreev (xmp_data); g_strfreev (xmp_data);
} }