[gnome-photos] base-item: Be more robust to malformed input



commit 7756eb3c1059ed9e346be253dcf49407c59b18df
Author: Debarshi Ray <debarshir gnome org>
Date:   Thu Aug 2 21:17:26 2012 +0200

    base-item: Be more robust to malformed input
    
    We can get any kind of results out of Tracker. So we should not assume
    that filename != NULL, when we don't have a title.
    
    Original patch from Cosimo Cecchi for gnome-documents.

 src/photos-base-item.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-base-item.c b/src/photos-base-item.c
index b77a016..d213b68 100644
--- a/src/photos-base-item.c
+++ b/src/photos-base-item.c
@@ -493,8 +493,13 @@ photos_base_item_populate_from_cursor (PhotosBaseItem *self, TrackerSparqlCursor
   title = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_TITLE, NULL);
   if (title == NULL || title[0] == '\0')
     {
-      title = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_FILENAME, NULL);
-      title = photos_utils_filename_strip_extension (title);
+      const gchar *filename;
+
+      filename = tracker_sparql_cursor_get_string (cursor, PHOTOS_QUERY_COLUMNS_FILENAME, NULL);
+      if (filename != NULL)
+        title = photos_utils_filename_strip_extension (filename);
+      else
+        title = "";
     }
   priv->name = g_strdup (title);
 



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