Skip to content
Snippets Groups Projects
Commit ac9c3232 authored by con's avatar con
Browse files

Avoid recursion and possibly endless recursion at removing file watches

Was introduced by the fix for QTCREATORBUG-965

Task-number: QTCREATORBUG-3116
Reviewed-by: dt
parent f9eea7e1
No related branches found
No related tags found
No related merge requests found
...@@ -297,34 +297,26 @@ void FileManager::renamedFile(const QString &from, QString &to) ...@@ -297,34 +297,26 @@ void FileManager::renamedFile(const QString &from, QString &to)
/// with renamed files and deleted files /// with renamed files and deleted files
void FileManager::removeFileInfo(IFile *file) void FileManager::removeFileInfo(IFile *file)
{ {
QString fileName;
QMap<QString, Internal::FileState>::const_iterator it, end; QMap<QString, Internal::FileState>::const_iterator it, end;
end = d->m_states.constEnd(); end = d->m_states.constEnd();
for (it = d->m_states.constBegin(); it != end; ++it) { for (it = d->m_states.constBegin(); it != end; ++it) {
if (it.value().lastUpdatedState.contains(file)) { if (it.value().lastUpdatedState.contains(file)) {
fileName = it.key(); removeFileInfo(it.key(), file);
break; break;
} }
} }
removeFileInfo(fileName, file);
} }
/* only called from removeFileInfo(IFile*) */
void FileManager::removeFileInfo(const QString &fileName, IFile *file) void FileManager::removeFileInfo(const QString &fileName, IFile *file)
{ {
const QString &fixedName = fixFileName(fileName); QTC_ASSERT(d->m_states.value(fileName).lastUpdatedState.contains(file), return);
if (d->m_states[fixedName].lastUpdatedState.contains(file)) { d->m_states[fileName].lastUpdatedState.remove(file);
d->m_states[fixedName].lastUpdatedState.remove(file); if (d->m_states.value(fileName).lastUpdatedState.isEmpty()) {
if (!fileName.isEmpty())
if (d->m_states.value(fixedName).lastUpdatedState.isEmpty()) { d->m_fileWatcher->removePath(fileName);
d->m_states.remove(fixedName); d->m_states.remove(fileName); // this deletes fileName
if (!fixedName.isEmpty()) {
d->m_fileWatcher->removePath(fixedName);
}
}
} else {
// We could not find the fileinfo, try harder to remove it
removeFileInfo(file);
} }
} }
...@@ -376,7 +368,7 @@ bool FileManager::removeFile(IFile *file) ...@@ -376,7 +368,7 @@ bool FileManager::removeFile(IFile *file)
disconnect(file, SIGNAL(changed()), this, SLOT(checkForNewFileName())); disconnect(file, SIGNAL(changed()), this, SLOT(checkForNewFileName()));
disconnect(file, SIGNAL(destroyed(QObject *)), this, SLOT(fileDestroyed(QObject *))); disconnect(file, SIGNAL(destroyed(QObject *)), this, SLOT(fileDestroyed(QObject *)));
removeFileInfo(file->fileName(), file); removeFileInfo(file);
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment