Utils: avoid another assert in FileSystemWatcher

amends f77635883b

Change-Id: I2b0f92db3218192457a08ff8a473444fd2f811a8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2023-10-17 09:31:46 +02:00
parent c2a470e853
commit f2934f8497

View File

@@ -470,20 +470,17 @@ void FileSystemWatcher::slotDirectoryChanged(const QString &path)
for (const QString &rejected : d->m_staticData->m_watcher->addPaths(toReadd))
toReadd.removeOne(rejected);
QStringList toRemove;
// If we've successfully added the file, that means it was deleted and replaced.
for (const QString &reAdded : std::as_const(toReadd)) {
d->fileChanged(reAdded);
const QString directory = QFileInfo(reAdded).path();
const int dirCount = --d->m_staticData->m_directoryCount[directory];
Q_ASSERT(dirCount >= 0);
if (!dirCount)
toRemove << directory;
}
d->m_staticData->m_watcher->removePath(directory);
if (!toRemove.isEmpty())
d->m_staticData->m_watcher->removePaths(toRemove);
d->fileChanged(reAdded);
}
}
}