KDirectoryContentsCounter: don't schedule scanning a folder already in the Queue

Use a QLinkedList to check for presence in the queue.

merge request !2
This commit is contained in:
Méven Car 2020-05-19 07:52:26 +02:00
parent 3c9972179b
commit eda05b12fb
2 changed files with 6 additions and 4 deletions

View file

@ -104,7 +104,7 @@ void KDirectoryContentsCounter::slotResult(const QString& path, int count, long
} }
if (!m_queue.isEmpty()) { if (!m_queue.isEmpty()) {
startWorker(m_queue.dequeue()); startWorker(m_queue.takeFirst());
} }
if (s_cache->contains(resolvedPath)) { if (s_cache->contains(resolvedPath)) {
@ -175,7 +175,9 @@ void KDirectoryContentsCounter::startWorker(const QString& path)
} }
if (m_workerIsBusy) { if (m_workerIsBusy) {
m_queue.enqueue(path); if (!m_queue.contains(path)) {
m_queue.append(path);
}
} else { } else {
KDirectoryContentsCounterWorker::Options options; KDirectoryContentsCounterWorker::Options options;

View file

@ -23,7 +23,7 @@
#include "kdirectorycontentscounterworker.h" #include "kdirectorycontentscounterworker.h"
#include <QQueue> #include <QLinkedList>
#include <QSet> #include <QSet>
#include <QHash> #include <QHash>
@ -72,7 +72,7 @@ private:
private: private:
KFileItemModel* m_model; KFileItemModel* m_model;
QQueue<QString> m_queue; QLinkedList<QString> m_queue;
static QThread* m_workerThread; static QThread* m_workerThread;