Commit b9d3c1f5 authored by Alessandro Portale's avatar Alessandro Portale

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
parent 043cf532
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment