summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2022-10-11 10:31:06 +0200
committerNiels De Graef <ndegraef@redhat.com>2022-10-11 10:38:05 +0200
commit6ba0c4b3fb4684670ef631c67482f1bbd4f7ea86 (patch)
treef394bedd74de8593b487338249d11a65c9dc9a53 /src
parentc2e72f699295d792fd790bfd5e4d48b5c646ceb6 (diff)
downloadgnome-contacts-6ba0c4b3fb4684670ef631c67482f1bbd4f7ea86.tar.gz
store: Make sure we don't add individuals twice
An individual can appear several times in the `changes` argument of the `IndividualAggregator`'s `individuals-changed-detailed` signal, in the case of linking. When 2 Individuals are linked -let's call them A and B- into a single Individual C, then the signal will be emitted with the following map: ``` A -> C B -> C ``` In other words, C will show up twice in the list of values. Since we weren't checking whether an individual already existed before adding it to the `to_add` list, duplicates were a possibility. This should no longer be the case (and from a quick check, it doesn't have any non-negligible performance impact either). Fixes: https://gitlab.gnome.org/GNOME/gnome-contacts/-/issues/247
Diffstat (limited to 'src')
-rw-r--r--src/contacts-store.vala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/contacts-store.vala b/src/contacts-store.vala
index 7a70cad..c359a37 100644
--- a/src/contacts-store.vala
+++ b/src/contacts-store.vala
@@ -188,7 +188,7 @@ public class Contacts.Store : GLib.Object {
if (individual != null)
to_remove.add (individual);
foreach (var new_i in changes[individual]) {
- if (new_i != null)
+ if (new_i != null && !to_add.find (new_i, null))
to_add.add (new_i);
}
}