]> cloud.milkyroute.net Git - dolphin.git/commitdiff
KDirectoryContentsCounter: don't schedule scanning a folder already in the Queue
authorMéven Car <meven29@gmail.com>
Tue, 19 May 2020 05:52:26 +0000 (07:52 +0200)
committerMéven Car <meven29@gmail.com>
Wed, 20 May 2020 05:45:58 +0000 (07:45 +0200)
Use a QLinkedList to check for presence in the queue.

merge request !2

src/kitemviews/private/kdirectorycontentscounter.cpp
src/kitemviews/private/kdirectorycontentscounter.h

index a19bce8b3b061cd6b0ba3685b2a4603257056510..a0ed8c27cadc0320dd3ec4b5d32f46b405a67a8a 100644 (file)
@@ -104,7 +104,7 @@ void KDirectoryContentsCounter::slotResult(const QString& path, int count, long
     }
 
     if (!m_queue.isEmpty()) {
-        startWorker(m_queue.dequeue());
+        startWorker(m_queue.takeFirst());
     }
 
     if (s_cache->contains(resolvedPath)) {
@@ -175,7 +175,9 @@ void KDirectoryContentsCounter::startWorker(const QString& path)
     }
 
     if (m_workerIsBusy) {
-        m_queue.enqueue(path);
+        if (!m_queue.contains(path)) {
+            m_queue.append(path);
+        }
     } else {
         KDirectoryContentsCounterWorker::Options options;
 
index 0c900ec644334ff12fc78f84da2cdda8a9275332..287227bffb76aba149226523dceff685b2ccf026 100644 (file)
@@ -23,7 +23,7 @@
 
 #include "kdirectorycontentscounterworker.h"
 
-#include <QQueue>
+#include <QLinkedList>
 #include <QSet>
 #include <QHash>
 
@@ -72,7 +72,7 @@ private:
 private:
     KFileItemModel* m_model;
 
-    QQueue<QString> m_queue;
+    QLinkedList<QString> m_queue;
 
     static QThread* m_workerThread;