解决移除监听失败的问题.

This commit is contained in:
iaom 2022-08-08 10:36:21 +08:00
parent a765943b1a
commit cce6136b20
1 changed files with 5 additions and 4 deletions

View File

@ -104,15 +104,16 @@ QStringList FileSystemWatcherPrivate::removeWatch(const QString &path)
{ {
m_pool->waitForDone(); m_pool->waitForDone();
QStringList paths; QStringList paths;
for(QHash<int, QString>::Iterator i = m_watchPathHash.begin(); i != m_watchPathHash.end();) { for(int wd : m_watchPathHash.keys()) {
if(i.value().length() > path.length()) { QString tmpPath = m_watchPathHash.value(wd);
if(FileUtils::isOrUnder(i.value(), path)) { if(tmpPath.length() >= path.length()) {
if(FileUtils::isOrUnder(tmpPath, path)) {
//fix me:This function can be slow (O(n)) //fix me:This function can be slow (O(n))
paths.append(removeWatch(m_watchPathHash.key(path))); paths.append(removeWatch(m_watchPathHash.key(path)));
} }
} }
i++;
} }
return paths; return paths;
} }