summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppmodelmanager.cpp
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@nokia.com>2010-10-03 09:23:48 +0200
committerAlessandro Portale <alessandro.portale@nokia.com>2010-10-03 09:23:48 +0200
commitb9d3c1f54ae4d952781a686b950f4b5f315bf5ac (patch)
tree13c1d70c9a434426f06926a164fe4694faf77378 /src/plugins/cpptools/cppmodelmanager.cpp
parent043cf532ecac1a3a69dd6af356e638012dc232ec (diff)
downloadqt-creator-b9d3c1f54ae4d952781a686b950f4b5f315bf5ac.tar.gz
No Samba while including files
(The other Samba is meant. The slow one, not the nice one.) Creator manages to feed the CppModelManager with all kinds of wrong include paths. That is usually not a big issue as long as that path is not a simple "/". CppManager appended a separator to all incoming include paths. And when the above "/" was passed in, we had (on my machine) 7 seconds of Samba Network lookup, multiple times during a parse. And the sad thing was that my dear colleagues in the Intranet did not even have the searched-for header files on their shared folders. This patch makes sure that a separator is only appended if the path does not already end with one. The real core of the issue (wrong include paths from Creator) still needs to be fixed. Done-with: Roberto Raggi
Diffstat (limited to 'src/plugins/cpptools/cppmodelmanager.cpp')
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index d1415bb281..69198cedf1 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -361,6 +361,12 @@ QString CppPreprocessor::tryIncludeFile(QString &fileName, IncludeType type, uns
return contents;
}
+static inline void appendDirSeparatorIfNeeded(QString &path)
+{
+ if (!path.endsWith(QLatin1Char('/'), Qt::CaseInsensitive))
+ path += QLatin1Char('/');
+}
+
QString CppPreprocessor::tryIncludeFile_helper(QString &fileName, IncludeType type, unsigned *revision)
{
QFileInfo fileInfo(fileName);
@@ -373,7 +379,7 @@ QString CppPreprocessor::tryIncludeFile_helper(QString &fileName, IncludeType ty
if (type == IncludeLocal && m_currentDoc) {
QFileInfo currentFileInfo(m_currentDoc->fileName());
QString path = currentFileInfo.absolutePath();
- path += QLatin1Char('/');
+ appendDirSeparatorIfNeeded(path);
path += fileName;
path = QDir::cleanPath(path);
QString contents;
@@ -385,7 +391,7 @@ QString CppPreprocessor::tryIncludeFile_helper(QString &fileName, IncludeType ty
foreach (const QString &includePath, m_includePaths) {
QString path = includePath;
- path += QLatin1Char('/');
+ appendDirSeparatorIfNeeded(path);
path += fileName;
path = QDir::cleanPath(path);
QString contents;
@@ -398,7 +404,7 @@ QString CppPreprocessor::tryIncludeFile_helper(QString &fileName, IncludeType ty
// look in the system include paths
foreach (const QString &includePath, m_systemIncludePaths) {
QString path = includePath;
- path += QLatin1Char('/');
+ appendDirSeparatorIfNeeded(path);
path += fileName;
path = QDir::cleanPath(path);
QString contents;
@@ -415,7 +421,7 @@ QString CppPreprocessor::tryIncludeFile_helper(QString &fileName, IncludeType ty
foreach (const QString &frameworkPath, m_frameworkPaths) {
QString path = frameworkPath;
- path += QLatin1Char('/');
+ appendDirSeparatorIfNeeded(path);
path += frameworkName;
path += QLatin1String(".framework/Headers/");
path += name;