]> cloud.milkyroute.net Git - dolphin.git/commitdiff
[FileItemRolesUpdater] Fix reservation size
authorStefan Brüns <stefan.bruens@rwth-aachen.de>
Mon, 15 Feb 2021 10:25:28 +0000 (11:25 +0100)
committerStefan Brüns <stefan.bruens@rwth-aachen.de>
Mon, 15 Feb 2021 16:24:15 +0000 (17:24 +0100)
The code below always adds the visible range, up to 5 pages before and
after the visible range (each capped to ResolveAllItemsLimit/2) and
the very first and last page (each up to m_maximumVisibleItems).

Use this number to avoid growing the list later.

src/kitemviews/kfileitemmodelrolesupdater.cpp

index 88a732f8debe052b261346743181269fbd663a3d..0554bff60e01deb999a7a1b23da6dd4526fc8228 100644 (file)
@@ -1160,7 +1160,9 @@ QList<int> KFileItemModelRolesUpdater::indexesToResolve() const
     const int count = m_model->count();
 
     QList<int> result;
-    result.reserve(ResolveAllItemsLimit);
+    result.reserve(qMin(count, (m_lastVisibleIndex - m_firstVisibleIndex + 1) +
+                               ResolveAllItemsLimit +
+                               (2 * m_maximumVisibleItems)));
 
     // Add visible items.
     for (int i = m_firstVisibleIndex; i <= m_lastVisibleIndex; ++i) {