diff --git a/src/libs/utils/fileinprojectfinder.cpp b/src/libs/utils/fileinprojectfinder.cpp index f7324176797..026ff20d59f 100644 --- a/src/libs/utils/fileinprojectfinder.cpp +++ b/src/libs/utils/fileinprojectfinder.cpp @@ -159,22 +159,22 @@ QString FileInProjectFinder::findFileOrDirectory(const QString &originalPath, Fi return originalPath; } + auto it = m_cache.find(originalPath); + if (it != m_cache.end()) { + if (debug) + qDebug() << "FileInProjectFinder: checking cache ..."; + // check if cached path is still there + const QString &candidate = it.value(); + if (checkPath(candidate, findMode)) + return handleSuccess(originalPath, candidate, success, "in the cache", false); + else + m_cache.erase(it); + } + if (!m_projectDir.isEmpty()) { if (debug) qDebug() << "FileInProjectFinder: checking project directory ..."; - auto it = m_cache.find(originalPath); - if (it != m_cache.end()) { - if (debug) - qDebug() << "FileInProjectFinder: checking cache ..."; - // check if cached path is still there - const QString &candidate = it.value(); - if (checkPath(candidate, findMode)) - return handleSuccess(originalPath, candidate, success, "in the cache", false); - else - m_cache.erase(it); - } - int prefixToIgnore = -1; const QChar separator = QLatin1Char('/'); if (originalPath.startsWith(m_projectDir + separator)) {