┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <[email protected]>2023-12-07 12:14:45 +0100
committerDavid Edmundson <[email protected]>2023-12-08 09:50:24 +0000
commit30691235c5acc4c5b30ffc8820d2ef7c55fc632e (patch)
treeb803ca2d8498a61a22af1b64cec8aeaa76a8894c
parent35235589aab7b18be6d12e19cb4c01c0f1268ee3 (diff)
Do not cache indexes across async tasks
Capturing an index is unsafe as it could be out of date when this is processed. The user could have changed directory inserted a file or changed sorting order.
-rw-r--r--src/kitemviews/kfileitemmodelrolesupdater.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp
index 06500b45d..bcd172d02 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.cpp
+++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp
@@ -1315,7 +1315,11 @@ void KFileItemModelRolesUpdater::startDirectorySizeCounting(const KFileItem &ite
connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged);
auto listJob = KIO::listDir(url, KIO::HideProgressInfo);
- QObject::connect(listJob, &KIO::ListJob::entries, this, [this, index](const KJob * /*job*/, const KIO::UDSEntryList &list) {
+ QObject::connect(listJob, &KIO::ListJob::entries, this, [this, item](const KJob * /*job*/, const KIO::UDSEntryList &list) {
+ int index = m_model->index(item);
+ if (index < 0) {
+ return;
+ }
auto data = m_model->data(index);
int origCount = data.value("count").toInt();
int entryCount = origCount;