[eog] EogExifDetails: Take Exif IFD into account when creating hash keys



commit 38f49dca4785b2e1a36c9c1fe6ba7d9c84f022a0
Author: Felix Riemann <friemann gnome org>
Date:   Sun Feb 26 15:51:23 2012 +0100

    EogExifDetails: Take Exif IFD into account when creating hash keys
    
    This should solve conflicts with Exif values that have the same number
    but are stored in different IFD blocks (e.g GPS and Interoperability).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=670700

 src/eog-exif-details.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/eog-exif-details.c b/src/eog-exif-details.c
index ed8fd78..878cfef 100644
--- a/src/eog-exif-details.c
+++ b/src/eog-exif-details.c
@@ -454,13 +454,22 @@ exif_entry_cb (ExifEntry *entry, gpointer data)
 	ExifIfd ifd = exif_entry_get_ifd (entry);
 	char *path;
 	char b[1024];
+	const gint key = ifd << 16 | entry->tag;
+
+	/* This should optimize away if comparision is correct */
+	g_warn_if_fail (EXIF_IFD_COUNT <= G_MAXUINT16);
 
 	view = EOG_EXIF_DETAILS (data);
 	priv = view->priv;
 
 	store = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
 
-	path = g_hash_table_lookup (priv->id_path_hash, GINT_TO_POINTER (entry->tag));
+	/* Take the tag's IFD into account when caching their GtkTreePaths.
+	 * That should fix key collisions for tags that have the same number
+	 * but are stored in different IFDs. Exif tag numbers are 16-bit
+	 * values so we should be able to set the high word to the IFD number.
+	 */
+	path = g_hash_table_lookup (priv->id_path_hash, GINT_TO_POINTER (key));
 
 	if (path != NULL) {
 		set_row_data (store,
@@ -503,7 +512,7 @@ exif_entry_cb (ExifEntry *entry, gpointer data)
 								    sizeof(b)));
 
 			g_hash_table_insert (priv->id_path_hash,
-					     GINT_TO_POINTER (entry->tag),
+					     GINT_TO_POINTER (key),
 					     path);
 		}
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]