diff --git a/src/libs/utils/fileinprojectfinder.cpp b/src/libs/utils/fileinprojectfinder.cpp index c0394d82898fbae780226411f3636b4794573a42..8f2671cb4a942d096c6d2a5bc6296367c75a1246 100644 --- a/src/libs/utils/fileinprojectfinder.cpp +++ b/src/libs/utils/fileinprojectfinder.cpp @@ -97,37 +97,36 @@ void FileInProjectFinder::setProjectFiles(const QStringList &projectFiles) */ QString FileInProjectFinder::findFile(const QString &originalPath, bool *success) const { - if (m_projectDir.isEmpty()) - return originalPath; - - const QChar separator = QLatin1Char('/'); - if (originalPath.startsWith(m_projectDir + separator)) { - if (success) - *success = true; - return originalPath; - } + if (!m_projectDir.isEmpty()) { + const QChar separator = QLatin1Char('/'); + if (originalPath.startsWith(m_projectDir + separator)) { + if (success) + *success = true; + return originalPath; + } - if (m_cache.contains(originalPath)) { - if (success) - *success = true; - return m_cache.value(originalPath); - } + if (m_cache.contains(originalPath)) { + if (success) + *success = true; + return m_cache.value(originalPath); + } - // Strip directories one by one from the beginning of the path, - // and see if the new relative path exists in the build directory. - if (originalPath.contains(separator)) { - for (int pos = originalPath.indexOf(separator); pos != -1; - pos = originalPath.indexOf(separator, pos + 1)) { - QString candidate = originalPath; - candidate.remove(0, pos); - candidate.prepend(m_projectDir); - QFileInfo candidateInfo(candidate); - if (candidateInfo.exists() && candidateInfo.isFile()) { - if (success) - *success = true; - - m_cache.insert(originalPath, candidate); - return candidate; + // Strip directories one by one from the beginning of the path, + // and see if the new relative path exists in the build directory. + if (originalPath.contains(separator)) { + for (int pos = originalPath.indexOf(separator); pos != -1; + pos = originalPath.indexOf(separator, pos + 1)) { + QString candidate = originalPath; + candidate.remove(0, pos); + candidate.prepend(m_projectDir); + QFileInfo candidateInfo(candidate); + if (candidateInfo.exists() && candidateInfo.isFile()) { + if (success) + *success = true; + + m_cache.insert(originalPath, candidate); + return candidate; + } } } }