plug-ins: fix saving of XMP BAG/SEQ array values in metadata-editor
XMP array tags of type BAG and SEQ can have multiple values, each of which is on a separate line. However, we were reading and saving it as just one value. We change this by setting each line as a separate value with gexiv2_metadata_set_tag_multiple. In addition to that we found that setting the type of tag struct with gexiv2_metadata_set_xmp_tag_struct caused arrays of multiple values per tag to be set incorrectly: the last value in the list got added multiple times. I'm not sure if we are using this function incorrectly, or that there is a bug in gexiv2 or exiv2. Anyway, since it seems that all tags and values I tested work without calling this function, let's just omit this call.
This commit is contained in:
parent
76dc649b3f
commit
a4cb134f14
1 changed files with 13 additions and 39 deletions
|
|
@ -4232,27 +4232,10 @@ metadata_editor_write_callback (GtkWidget *dialog,
|
|||
set_tag_failed (default_metadata_tags[i].tag);
|
||||
}
|
||||
}
|
||||
else if (default_metadata_tags[i].xmp_type == GIMP_XMP_BAG)
|
||||
else
|
||||
{
|
||||
gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag);
|
||||
gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag,
|
||||
GEXIV2_STRUCTURE_XA_BAG);
|
||||
if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag,
|
||||
text_value))
|
||||
{
|
||||
set_tag_failed (default_metadata_tags[i].tag);
|
||||
}
|
||||
}
|
||||
else if (default_metadata_tags[i].xmp_type == GIMP_XMP_SEQ)
|
||||
{
|
||||
gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag);
|
||||
gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag,
|
||||
GEXIV2_STRUCTURE_XA_SEQ);
|
||||
if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag,
|
||||
text_value))
|
||||
|
|
@ -4309,33 +4292,24 @@ metadata_editor_write_callback (GtkWidget *dialog,
|
|||
set_tag_failed (default_metadata_tags[i].tag);
|
||||
}
|
||||
}
|
||||
else if (default_metadata_tags[i].xmp_type == GIMP_XMP_BAG)
|
||||
else
|
||||
{
|
||||
gchar **multi;
|
||||
|
||||
gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag);
|
||||
gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag,
|
||||
GEXIV2_STRUCTURE_XA_BAG);
|
||||
if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag,
|
||||
text))
|
||||
{
|
||||
set_tag_failed (default_metadata_tags[i].tag);
|
||||
}
|
||||
}
|
||||
else if (default_metadata_tags[i].xmp_type == GIMP_XMP_SEQ)
|
||||
{
|
||||
gexiv2_metadata_clear_tag (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag);
|
||||
gexiv2_metadata_set_xmp_tag_struct (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag,
|
||||
GEXIV2_STRUCTURE_XA_SEQ);
|
||||
if (! gexiv2_metadata_set_tag_string (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag,
|
||||
text))
|
||||
|
||||
/* We have one value per line. */
|
||||
multi = g_strsplit (text, "\n", 0);
|
||||
|
||||
if (! gexiv2_metadata_set_tag_multiple (GEXIV2_METADATA (g_metadata),
|
||||
default_metadata_tags[i].tag,
|
||||
(const gchar **) multi))
|
||||
{
|
||||
set_tag_failed (default_metadata_tags[i].tag);
|
||||
}
|
||||
|
||||
g_strfreev (multi);
|
||||
}
|
||||
|
||||
index = default_metadata_tags[i].other_tag_index;
|
||||
|
|
|
|||
Loading…
Reference in a new issue