[gthumb] Fixed crash when saving images with comments
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] Fixed crash when saving images with comments
- Date: Tue, 24 Aug 2010 11:46:54 +0000 (UTC)
commit c2840c325e20f6435fcaeef500552cbe4fd1595c
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Aug 24 13:44:22 2010 +0200
Fixed crash when saving images with comments
Set the corrent value type for each metadatum.
.../exiv2_tools/gth-metadata-provider-exiv2.c | 29 +++++++++++++++++--
extensions/exiv2_tools/main.c | 1 +
gthumb/gth-metadata.c | 18 ++++++++++++
gthumb/gth-metadata.h | 1 +
4 files changed, 46 insertions(+), 3 deletions(-)
---
diff --git a/extensions/exiv2_tools/gth-metadata-provider-exiv2.c b/extensions/exiv2_tools/gth-metadata-provider-exiv2.c
index 1181c77..6a41daa 100644
--- a/extensions/exiv2_tools/gth-metadata-provider-exiv2.c
+++ b/extensions/exiv2_tools/gth-metadata-provider-exiv2.c
@@ -140,14 +140,37 @@ gth_metadata_provider_exiv2_write (GthMetadataProvider *self,
"Iptc::Application2::Headline",
NULL
};
+ const char *tags_to_update[] = {
+ "Exif::Photo::UserComment",
+ "Xmp::dc::description",
+ "Iptc::Application2::Caption",
+ NULL
+ };
int i;
for (i = 0; tags_to_remove[i] != NULL; i++)
g_file_info_remove_attribute (file_data->info, tags_to_remove[i]);
- g_file_info_set_attribute_object (file_data->info, "Exif::Photo::UserComment", metadata);
- g_file_info_set_attribute_object (file_data->info, "Xmp::dc::description", metadata);
- g_file_info_set_attribute_object (file_data->info, "Iptc::Application2::Caption", metadata);
+ /* Remove the value type to use the default type for each field
+ * as described in exiv2_tools/main.c */
+
+ g_object_set (metadata, "value-type", NULL, NULL);
+
+ for (i = 0; tags_to_update[i] != NULL; i++) {
+ GObject *orig_metadata;
+
+ orig_metadata = g_file_info_get_attribute_object (file_data->info, tags_to_update[i]);
+ if (orig_metadata != NULL) {
+ /* keep the original value type */
+
+ g_object_set (orig_metadata,
+ "raw", gth_metadata_get_raw (GTH_METADATA (metadata)),
+ "formatted", gth_metadata_get_formatted (GTH_METADATA (metadata)),
+ NULL);
+ }
+ else
+ g_file_info_set_attribute_object (file_data->info, tags_to_update[i], metadata);
+ }
}
metadata = g_file_info_get_attribute_object (file_data->info, "general::title");
diff --git a/extensions/exiv2_tools/main.c b/extensions/exiv2_tools/main.c
index 23c775f..24f114e 100644
--- a/extensions/exiv2_tools/main.c
+++ b/extensions/exiv2_tools/main.c
@@ -145,6 +145,7 @@ GthMetadataInfo exiv2_metadata_info[] = {
{ "Exif::Photo::RelatedImageLength", NULL, "Exif::Versions", 9, NULL, GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Exif::Photo::MakerNote", NULL, "Exif::Other", 0, NULL, GTH_METADATA_ALLOW_NOWHERE },
+ { "Exif::Photo::UserComment", NULL, "Exif::Other", 1, "Ascii", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Xmp::dc::description", NULL, "Xmp::Embedded", 0, "XmpText", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
{ "Xmp::dc::title", NULL, "Xmp::Embedded", 0, "XmpText", GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW },
diff --git a/gthumb/gth-metadata.c b/gthumb/gth-metadata.c
index c7e9d71..e51dcf8 100644
--- a/gthumb/gth-metadata.c
+++ b/gthumb/gth-metadata.c
@@ -244,6 +244,24 @@ gth_metadata_get_value_type (GthMetadata *metadata)
}
+GthMetadata *
+gth_metadata_dup (GthMetadata *metadata)
+{
+ GthMetadata *new_metadata;
+
+ new_metadata = gth_metadata_new ();
+ g_object_set (new_metadata,
+ "id", metadata->priv->id,
+ "description", metadata->priv->description,
+ "raw", metadata->priv->raw,
+ "formatted", metadata->priv->formatted,
+ "value-type", metadata->priv->value_type,
+ NULL);
+
+ return new_metadata;
+}
+
+
GthMetadataInfo *
gth_metadata_info_dup (GthMetadataInfo *info)
{
diff --git a/gthumb/gth-metadata.h b/gthumb/gth-metadata.h
index b532dc2..9f2f41a 100644
--- a/gthumb/gth-metadata.h
+++ b/gthumb/gth-metadata.h
@@ -77,6 +77,7 @@ const char * gth_metadata_get_id (GthMetadata *metadata);
const char * gth_metadata_get_raw (GthMetadata *metadata);
const char * gth_metadata_get_formatted (GthMetadata *metadata);
const char * gth_metadata_get_value_type (GthMetadata *metadata);
+GthMetadata * gth_metadata_dup (GthMetadata *metadata);
GthMetadataInfo * gth_metadata_info_dup (GthMetadataInfo *info);
void set_attribute_from_string (GFileInfo *info,
const char *key,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]