]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/private/kdirectorycontentscounter.cpp
Fix selection rect after porting from QFontMetrics::width()
[dolphin.git] / src / kitemviews / private / kdirectorycontentscounter.cpp
index a19bce8b3b061cd6b0ba3685b2a4603257056510..608f9f582a372dad6c853a2697b834bbda7752c8 100644 (file)
@@ -103,8 +103,14 @@ void KDirectoryContentsCounter::slotResult(const QString& path, int count, long
         m_watchedDirs.insert(resolvedPath);
     }
 
-    if (!m_queue.isEmpty()) {
-        startWorker(m_queue.dequeue());
+    if (!m_priorityQueue.empty()) {
+        const QString firstPath = m_priorityQueue.front();
+        m_priorityQueue.pop_front();
+        startWorker(firstPath);
+    } else if (!m_queue.empty()) {
+        const QString firstPath = m_queue.front();
+        m_queue.pop_front();
+        startWorker(firstPath);
     }
 
     if (s_cache->contains(resolvedPath)) {
@@ -167,7 +173,8 @@ void KDirectoryContentsCounter::slotItemsRemoved()
 
 void KDirectoryContentsCounter::startWorker(const QString& path)
 {
-    if (s_cache->contains(path)) {
+    const bool alreadyInCache = s_cache->contains(path);
+    if (alreadyInCache) {
         // fast path when in cache
         // will be updated later if result has changed
         const auto pair = s_cache->value(path);
@@ -175,7 +182,15 @@ void KDirectoryContentsCounter::startWorker(const QString& path)
     }
 
     if (m_workerIsBusy) {
-        m_queue.enqueue(path);
+        if (std::find(m_queue.begin(), m_queue.end(), path) == m_queue.end() &&
+            std::find(m_priorityQueue.begin(), m_priorityQueue.end(), path) == m_priorityQueue.end()) {
+            if (alreadyInCache) {
+                m_queue.push_back(path);
+            } else {
+                // append to priority queue
+                m_priorityQueue.push_back(path);
+            }
+        }
     } else {
         KDirectoryContentsCounterWorker::Options options;