aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>2009-08-28 16:54:38 +0200
committercon <qtc-committer@nokia.com>2009-08-31 11:03:07 +0200
commitd35e02b8da13620b622f9e31a8cb1c972dbc7c0c (patch)
tree8238951dbcd6823ac81001fc984e1b539cf84bfa
parentfc12d31ac48f3c1fb4b3de41369d3b10dc22ce37 (diff)
Fixed endless looping in include paths in some cases with symlinks
Done-with: Christian Kamm <christian.d.kamm@nokia.com> (cherry picked from commit 20e3d536021bce6b1e80ba64f19a7045d67b6b1a)
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index 6b6c2bbf95..b0b1e7a669 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -1099,6 +1099,9 @@ void CppModelManager::updateIncludesInPaths(QFutureInterface<void> &future,
QStringList suffixes)
{
QMap<QString, QStringList> entriesInPaths;
+ typedef QPair<QString, QString> SymLink;
+ typedef QList<SymLink> SymLinks;
+ SymLinks symlinks;
int processed = 0;
future.setProgressRange(0, paths.size());
@@ -1111,6 +1114,11 @@ void CppModelManager::updateIncludesInPaths(QFutureInterface<void> &future,
break;
const QString path = paths.takeFirst();
+
+ // Skip already scanned paths
+ if (entriesInPaths.contains(path))
+ continue;
+
QStringList entries;
QDirIterator i(path, QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
@@ -1125,11 +1133,18 @@ void CppModelManager::updateIncludesInPaths(QFutureInterface<void> &future,
// Also scan subdirectory, but avoid endless recursion with symbolic links
if (fileInfo.isSymLink()) {
- QMap<QString, QStringList>::const_iterator result = entriesInPaths.find(fileInfo.canonicalFilePath());
+ QString target = fileInfo.symLinkTarget();
+
+ // Don't add broken symlinks
+ if (!QFileInfo(target).exists())
+ continue;
+
+ QMap<QString, QStringList>::const_iterator result = entriesInPaths.find(target);
if (result != entriesInPaths.constEnd()) {
entriesInPaths.insert(fileName, result.value());
} else {
- paths.append(fileName);
+ paths.append(target);
+ symlinks.append(SymLink(fileName, target));
}
} else {
paths.append(fileName);
@@ -1145,6 +1160,14 @@ void CppModelManager::updateIncludesInPaths(QFutureInterface<void> &future,
future.setProgressRange(0, processed + paths.size());
future.setProgressValue(processed);
}
+ // link symlinks
+ QListIterator<SymLink> it(symlinks);
+ it.toBack();
+ while (it.hasPrevious()) {
+ SymLink v = it.previous();
+ QMap<QString, QStringList>::const_iterator result = entriesInPaths.find(v.second);
+ entriesInPaths.insert(v.first, result.value());
+ }
manager->setIncludesInPaths(entriesInPaths);