From a5211130f39b0e5bec7ab512c9ff23a23fc71e3a Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 11 Oct 2011 15:17:44 +0200 Subject: [PATCH] FileInProjectFinder: Normalize project directory before checking for changes Change-Id: Ia6ee0b0f8110add4a54bd470831d457dbb17c9c9 Reviewed-on: http://codereview.qt-project.org/6439 Sanity-Review: Qt Sanity Bot Reviewed-by: Aurindam Jana --- src/libs/utils/fileinprojectfinder.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/libs/utils/fileinprojectfinder.cpp b/src/libs/utils/fileinprojectfinder.cpp index d0f3b82f8c6..45c42245d4f 100644 --- a/src/libs/utils/fileinprojectfinder.cpp +++ b/src/libs/utils/fileinprojectfinder.cpp @@ -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(); }