From cce6136b209ff407f6102d9b19c19eb98e0a0fad Mon Sep 17 00:00:00 2001 From: iaom Date: Mon, 8 Aug 2022 10:36:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=A7=BB=E9=99=A4=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsearch/filesystemwatcher/file-system-watcher.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libsearch/filesystemwatcher/file-system-watcher.cpp b/libsearch/filesystemwatcher/file-system-watcher.cpp index 85b25fe..a72a40d 100644 --- a/libsearch/filesystemwatcher/file-system-watcher.cpp +++ b/libsearch/filesystemwatcher/file-system-watcher.cpp @@ -104,15 +104,16 @@ QStringList FileSystemWatcherPrivate::removeWatch(const QString &path) { m_pool->waitForDone(); QStringList paths; - for(QHash::Iterator i = m_watchPathHash.begin(); i != m_watchPathHash.end();) { - if(i.value().length() > path.length()) { - if(FileUtils::isOrUnder(i.value(), path)) { + for(int wd : m_watchPathHash.keys()) { + QString tmpPath = m_watchPathHash.value(wd); + if(tmpPath.length() >= path.length()) { + if(FileUtils::isOrUnder(tmpPath, path)) { //fix me:This function can be slow (O(n)) paths.append(removeWatch(m_watchPathHash.key(path))); } } - i++; } + return paths; }