From 2e1f75708e04896464a83869b3fcdd5969705316 Mon Sep 17 00:00:00 2001 From: Niels De Graef Date: Thu, 8 Sep 2022 07:50:08 +0200 Subject: 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. --- src/contacts-store.vala | 6 ++++-- 1 file 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 -- cgit v1.2.1