FileInProjectFinder: Normalize project directory before checking for changes

Change-Id: Ia6ee0b0f8110add4a54bd470831d457dbb17c9c9
Reviewed-on: http://codereview.qt-project.org/6439
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aurindam Jana <aurindam.jana@nokia.com>
This commit is contained in:
Kai Koehne
2011-10-11 15:17:44 +02:00
parent 8c8f5270c2
commit a5211130f3

View File

@@ -60,18 +60,26 @@ FileInProjectFinder::FileInProjectFinder()
{
}
static QString stripTrailingSlashes(const QString &path)
{
QString newPath = path;
while (newPath.endsWith(QLatin1Char('/')))
newPath.remove(newPath.length() - 1, 1);
return newPath;
}
void FileInProjectFinder::setProjectDirectory(const QString &absoluteProjectPath)
{
QTC_ASSERT(QFileInfo(absoluteProjectPath).exists()
&& QFileInfo(absoluteProjectPath).isAbsolute(), return);
const QString newProjectPath = stripTrailingSlashes(absoluteProjectPath);
if (absoluteProjectPath == m_projectDir)
if (newProjectPath == m_projectDir)
return;
m_projectDir = absoluteProjectPath;
while (m_projectDir.endsWith(QLatin1Char('/')))
m_projectDir.remove(m_projectDir.length() - 1, 1);
const QFileInfo infoPath(newProjectPath);
QTC_CHECK(newProjectPath.isEmpty()
|| infoPath.exists() && infoPath.isAbsolute());
m_projectDir = newProjectPath;
m_cache.clear();
}
@@ -82,6 +90,9 @@ QString FileInProjectFinder::projectDirectory() const
void FileInProjectFinder::setProjectFiles(const QStringList &projectFiles)
{
if (m_projectFiles == projectFiles)
return;
m_projectFiles = projectFiles;
m_cache.clear();
}