From 85241a9246171b11119f81de0974d6fb438a5a46 Mon Sep 17 00:00:00 2001 From: Elvis Angelaccio Date: Sun, 5 Jul 2020 18:21:20 +0200 Subject: [PATCH] Port away from QLinkedList `QLinkedList` has been deprecated and should not be used in new code. Port to `std::list` instead. --- .../private/kdirectorycontentscounter.cpp | 19 ++++++++++++------- .../private/kdirectorycontentscounter.h | 5 ++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/kitemviews/private/kdirectorycontentscounter.cpp b/src/kitemviews/private/kdirectorycontentscounter.cpp index 4d6a4861c..608f9f582 100644 --- a/src/kitemviews/private/kdirectorycontentscounter.cpp +++ b/src/kitemviews/private/kdirectorycontentscounter.cpp @@ -103,10 +103,14 @@ void KDirectoryContentsCounter::slotResult(const QString& path, int count, long m_watchedDirs.insert(resolvedPath); } - if (!m_priorityQueue.isEmpty()) { - startWorker(m_priorityQueue.takeFirst()); - } else if (!m_queue.isEmpty()) { - startWorker(m_queue.takeFirst()); + 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)) { @@ -178,12 +182,13 @@ void KDirectoryContentsCounter::startWorker(const QString& path) } if (m_workerIsBusy) { - if (!m_queue.contains(path) && !m_priorityQueue.contains(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.append(path); + m_queue.push_back(path); } else { // append to priority queue - m_priorityQueue.append(path); + m_priorityQueue.push_back(path); } } } else { diff --git a/src/kitemviews/private/kdirectorycontentscounter.h b/src/kitemviews/private/kdirectorycontentscounter.h index 65c4bcb1b..d5baf3462 100644 --- a/src/kitemviews/private/kdirectorycontentscounter.h +++ b/src/kitemviews/private/kdirectorycontentscounter.h @@ -23,7 +23,6 @@ #include "kdirectorycontentscounterworker.h" -#include #include #include @@ -73,8 +72,8 @@ private: KFileItemModel* m_model; // Used as FIFO queues. - QLinkedList m_priorityQueue; - QLinkedList m_queue; + std::list m_priorityQueue; + std::list m_queue; static QThread* m_workerThread; -- 2.47.3