summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2022-10-11 10:31:06 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2023-02-06 09:11:47 +0100
commit78c0d7aaa19b5b4fb8a491d9b13e8da6ad66fefb (patch)
tree810ebecac1ccb0cdd1e6c74739b9e41645e53ed9
parentfcbe48124942bfd7d685e85ec1e723343038226f (diff)
downloadgnome-contacts-78c0d7aaa19b5b4fb8a491d9b13e8da6ad66fefb.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 (cherry picked from commit 6ba0c4b3fb4684670ef631c67482f1bbd4f7ea86)
-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);
}
}