[gnome-photos] base-manager: Be careful about objects with blank filters



commit 584c658fd4e9a59c966149b2cb5f66525536be52
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Jan 14 09:38:07 2014 +0100

    base-manager: Be careful about objects with blank filters
    
    When generating a filter for "all", an object with a blank filter, ie.
    "(true)", should be skipped. Otherwise it will lead to
    "(true) || cond1 || cond2 ...", rendering the whole filter useless.
    
    Fixes: https://bugzilla.gnome.org/709367

 src/photos-base-manager.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/photos-base-manager.c b/src/photos-base-manager.c
index 0c20f97..8598745 100644
--- a/src/photos-base-manager.c
+++ b/src/photos-base-manager.c
@@ -76,6 +76,7 @@ photos_base_manager_get_all_filter (PhotosBaseManager *self)
 {
   GList *l;
   GList *values;
+  const gchar *blank = "(true)";
   gchar *filter;
   gchar **strv;
   gchar *tmp;
@@ -93,12 +94,24 @@ photos_base_manager_get_all_filter (PhotosBaseManager *self)
       g_object_get (l->data, "id", &id, NULL);
       if (g_strcmp0 (id, "all") != 0)
         {
-          strv[i] = photos_filterable_get_filter (PHOTOS_FILTERABLE (l->data));
-          i++;
+          gchar *str;
+
+          str = photos_filterable_get_filter (PHOTOS_FILTERABLE (l->data));
+          if (g_strcmp0 (str, blank) == 0)
+            g_free (str);
+          else
+            {
+              strv[i] = str;
+              i++;
+            }
         }
       g_free (id);
     }
 
+  length = g_strv_length (strv);
+  if (length == 0)
+    strv[0] = g_strdup (blank);
+
   filter = g_strjoinv (" || ", strv);
   g_strfreev (strv);
 


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