forked from qt-creator/qt-creator
Utils: avoid another assert in FileSystemWatcher
amends f77635883b
Change-Id: I2b0f92db3218192457a08ff8a473444fd2f811a8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -470,20 +470,17 @@ void FileSystemWatcher::slotDirectoryChanged(const QString &path)
|
|||||||
for (const QString &rejected : d->m_staticData->m_watcher->addPaths(toReadd))
|
for (const QString &rejected : d->m_staticData->m_watcher->addPaths(toReadd))
|
||||||
toReadd.removeOne(rejected);
|
toReadd.removeOne(rejected);
|
||||||
|
|
||||||
QStringList toRemove;
|
|
||||||
// If we've successfully added the file, that means it was deleted and replaced.
|
// If we've successfully added the file, that means it was deleted and replaced.
|
||||||
for (const QString &reAdded : std::as_const(toReadd)) {
|
for (const QString &reAdded : std::as_const(toReadd)) {
|
||||||
d->fileChanged(reAdded);
|
|
||||||
const QString directory = QFileInfo(reAdded).path();
|
const QString directory = QFileInfo(reAdded).path();
|
||||||
const int dirCount = --d->m_staticData->m_directoryCount[directory];
|
const int dirCount = --d->m_staticData->m_directoryCount[directory];
|
||||||
Q_ASSERT(dirCount >= 0);
|
Q_ASSERT(dirCount >= 0);
|
||||||
|
|
||||||
if (!dirCount)
|
if (!dirCount)
|
||||||
toRemove << directory;
|
d->m_staticData->m_watcher->removePath(directory);
|
||||||
}
|
|
||||||
|
|
||||||
if (!toRemove.isEmpty())
|
d->fileChanged(reAdded);
|
||||||
d->m_staticData->m_watcher->removePaths(toRemove);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user