[rygel] tracker: Avoid duplicate triplets in queries



commit 76aebf52960457ec607894ac69ed5d02fa0a65a2
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Jul 6 19:35:50 2010 +0300

    tracker: Avoid duplicate triplets in queries

 .../tracker/rygel-tracker-query-triplets.vala      |    8 ++++++++
 .../tracker/rygel-tracker-search-container.vala    |   19 ++++++++++---------
 2 files changed, 18 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-query-triplets.vala b/src/plugins/tracker/rygel-tracker-query-triplets.vala
index 03f8c8c..fbda3d7 100644
--- a/src/plugins/tracker/rygel-tracker-query-triplets.vala
+++ b/src/plugins/tracker/rygel-tracker-query-triplets.vala
@@ -37,4 +37,12 @@ public class Rygel.TrackerQueryTriplets : ArrayList<TrackerQueryTriplet> {
             this.add (new TrackerQueryTriplet.clone (triplet));
         }
     }
+
+    // FIXME: Remove this method and override 'add' method from the base class
+    //        instead once bug#623685 is fixed.
+    public void add_triplet (TrackerQueryTriplet triplet) {
+        if (!this.contains (triplet)) {
+            this.add (triplet);
+        }
+    }
 }
diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala
index e296ce1..1548cec 100644
--- a/src/plugins/tracker/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker/rygel-tracker-search-container.vala
@@ -65,15 +65,16 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
             our_triplets = new TrackerQueryTriplets ();
         }
 
-        our_triplets.add (new TrackerQueryTriplet (ITEM_VARIABLE,
-                                                   "a",
-                                                   item_factory.category));
-        our_triplets.add (new TrackerQueryTriplet (ITEM_VARIABLE,
-                                                   MODIFIED_PREDICATE,
-                                                   MODIFIED_VARIABLE));
-        our_triplets.add (new TrackerQueryTriplet (ITEM_VARIABLE,
-                                                   URL_PREDICATE,
-                                                   URL_VARIABLE));
+        our_triplets.add_triplet (new TrackerQueryTriplet (
+                                        ITEM_VARIABLE,
+                                        "a",
+                                        item_factory.category));
+        our_triplets.add_triplet (new TrackerQueryTriplet (ITEM_VARIABLE,
+                                                           MODIFIED_PREDICATE,
+                                                           MODIFIED_VARIABLE));
+        our_triplets.add_triplet (new TrackerQueryTriplet (ITEM_VARIABLE,
+                                                           URL_PREDICATE,
+                                                           URL_VARIABLE));
 
         foreach (var chain in this.item_factory.key_chains) {
             var variable = ITEM_VARIABLE;



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