From f2934f84973db0f8cd4157a226a031cf87911212 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 17 Oct 2023 09:31:46 +0200 Subject: [PATCH] Utils: avoid another assert in FileSystemWatcher amends f77635883b0777fd7b852a40c2ef60955df4bf34 Change-Id: I2b0f92db3218192457a08ff8a473444fd2f811a8 Reviewed-by: Christian Stenger --- src/libs/utils/filesystemwatcher.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libs/utils/filesystemwatcher.cpp b/src/libs/utils/filesystemwatcher.cpp index d410ff2507f..ac9043f878c 100644 --- a/src/libs/utils/filesystemwatcher.cpp +++ b/src/libs/utils/filesystemwatcher.cpp @@ -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); + } } }