Annotate debug_exception() with source file, line, and function.
[geeqie.git] / src / exiv2.cc
index 624245d..455c8d3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Geeqie
- * Copyright (C) 2008 - 2009 The Geeqie Team
+ * Copyright (C) 2008 - 2012 The Geeqie Team
  *
  * Author: Vladimir Nadvornik
  *
@@ -101,13 +101,18 @@ static const AltKey alt_keys[] = {
        {NULL, NULL, NULL}
        };
 
-static void debug_exception(Exiv2::AnyError& e)
+static void _debug_exception(const char* file,
+                             int line,
+                             const char* func,
+                             Exiv2::AnyError& e)
 {
        gchar *str = g_locale_from_utf8(e.what(), -1, NULL, NULL, NULL);
-       DEBUG_1("Exiv2: %s", str);
+       DEBUG_1("%s:%d:%s:Exiv2: %s", file, line, func, str);
        g_free(str);
 }
 
+#define debug_exception(e) _debug_exception(__FILE__, __LINE__, __func__, e)
+
 struct _ExifData
 {
        Exiv2::ExifData::const_iterator exifIter; /* for exif_get_next_item */
@@ -797,7 +802,7 @@ gchar *exif_item_get_string(ExifItem *item, int idx)
 gint exif_item_get_integer(ExifItem *item, gint *value)
 {
        try {
-               if (!item) return 0;
+               if (!item || exif_item_get_elements(item) == 0) return 0;
                *value = ((Exiv2::Metadatum *)item)->toLong();
                return 1;
        }
@@ -1009,11 +1014,11 @@ static GList *exif_add_value_to_glist(GList *list, Exiv2::Metadatum &item, Metad
                else
                        {
                        str = item.toString();
-                       if (str.length() > 5 && str.substr(0, 5) == "lang=")
-                               {
-                               std::string::size_type pos = str.find_first_of(' ');
-                               if (pos != std::string::npos) str = str.substr(pos+1);
-                               }
+                       }
+               if (str.length() > 5 && str.substr(0, 5) == "lang=")
+                       {
+                       std::string::size_type pos = str.find_first_of(' ');
+                       if (pos != std::string::npos) str = str.substr(pos+1);
                        }
                list = g_list_append(list, utf8_validate_or_convert(str.c_str())); 
 #if EXIV2_TEST_VERSION(0,16,0)