From ee4ab8ce699bd0fd10fe664e053eb6f26da94268 Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Fri, 6 Nov 2020 21:22:14 +0100 Subject: Iterate over a const copy list of containers This effectively reverts the mutable iterations approach on 2448f88c5f42d7a2040fcf3bcd3c5f2a2f62cd03, and fix crashes and ghost items when using the filter bar BUG: 428374 --- src/kitemviews/kfileitemmodelrolesupdater.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/kitemviews/kfileitemmodelrolesupdater.cpp') diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index 25e1a3685..f6f2815df 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -957,9 +957,9 @@ void KFileItemModelRolesUpdater::updateChangedItems() QList visibleChangedIndexes; QList invisibleChangedIndexes; - QMutableSetIterator it(m_changedItems); - while (it.hasNext()) { - const KFileItem item = it.next(); + // Iterate over a const copy because items are deleted within the loop + const auto changedItems = m_changedItems; + for (const KFileItem item : changedItems) { const int index = m_model->index(item); if (index < 0) { -- cgit v1.3.1 From f6327ffec89a33623983e0ed1cc09f46aeedc91c Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Sun, 8 Nov 2020 23:23:07 +0100 Subject: Add missing reference --- src/kitemviews/kfileitemmodelrolesupdater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/kitemviews/kfileitemmodelrolesupdater.cpp') diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index f6f2815df..f27c421b4 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -959,7 +959,7 @@ void KFileItemModelRolesUpdater::updateChangedItems() // Iterate over a const copy because items are deleted within the loop const auto changedItems = m_changedItems; - for (const KFileItem item : changedItems) { + for (const KFileItem &item : changedItems) { const int index = m_model->index(item); if (index < 0) { -- cgit v1.3.1