summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNiels De Graef <nielsdegraef@gmail.com>2022-09-08 07:50:08 +0200
committerNiels De Graef <nielsdegraef@gmail.com>2022-09-08 07:58:15 +0200
commit2e1f75708e04896464a83869b3fcdd5969705316 (patch)
treefa9cd598563a077a9db9980d1b3ae99c1727ee53 /src
parent7831ea3d4b4cd7fa11a9538317c1bd1a5af80043 (diff)
downloadgnome-contacts-2e1f75708e04896464a83869b3fcdd5969705316.tar.gz
store: Fix ignoring newly added individuals
Apparently, Vala isn't smart enough to be able to deal with a `foreach` statement and remove elements at the same time, leading to some unexpected results. This commit fixes it by just using a classic index-based `for`-loop.
Diffstat (limited to 'src')
-rw-r--r--src/contacts-store.vala6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/contacts-store.vala b/src/contacts-store.vala
index 6a39240..7a70cad 100644
--- a/src/contacts-store.vala
+++ b/src/contacts-store.vala
@@ -207,9 +207,11 @@ public class Contacts.Store : GLib.Object {
}
// Add new individuals
- foreach (unowned var indiv in to_add) {
+ for (uint i = 0; i < to_add.length; i++) {
+ unowned var indiv = to_add[i];
if (indiv.personas.size == 0 || Utils.is_ignorable (indiv)) {
- to_add.remove_fast (indiv);
+ to_add.remove_index_fast (i);
+ i--;
} else {
// We want to make sure that changes in the Individual triggers changes
// in the list model if it affects sorting and/or filtering. Atm, the