tracker: Make sure ID's of children are unique
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Fri, 4 Dec 2009 17:02:11 +0000 (19:02 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Fri, 4 Dec 2009 17:02:11 +0000 (19:02 +0200)
Make sure children of MetadataValues have unique IDs.

src/plugins/tracker/rygel-tracker-metadata-values.vala

index 3b666a6..7c9d4f9 100644 (file)
@@ -144,6 +144,10 @@ public class Rygel.TrackerMetadataValues : Rygel.SimpleContainer {
             }
 
             var id = this.id_func (value);
+            if (!this.is_child_id_unique (id)) {
+                continue;
+            }
+
             var title = this.title_func (value);
 
             // The child container can use the same mandatory triplets we used
@@ -183,5 +187,19 @@ public class Rygel.TrackerMetadataValues : Rygel.SimpleContainer {
                                                 RESOURCES_PATH)
                                                 as TrackerResourcesIface;
     }
+
+    private bool is_child_id_unique (string child_id) {
+        var unique = true;
+
+        foreach (var child in this.children) {
+            if (child.id == child_id) {
+                unique = false;
+
+                break;
+            }
+        }
+
+        return unique;
+    }
 }