FileInProjectFinder: Do not overwrite result list in loop

Change-Id: Idadb7fcc43f816ea202b620472144392dd1e338e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-03-18 16:45:26 +01:00
committed by hjk
parent 1e3653992e
commit 890a7c616a

View File

@@ -464,20 +464,20 @@ FileInProjectFinder::PathMappingNode::~PathMappingNode()
FileNameList FileInProjectFinder::QrcUrlFinder::find(const QUrl &fileUrl) const FileNameList FileInProjectFinder::QrcUrlFinder::find(const QUrl &fileUrl) const
{ {
FileNameList result;
const auto fileIt = m_fileCache.constFind(fileUrl); const auto fileIt = m_fileCache.constFind(fileUrl);
if (fileIt != m_fileCache.cend()) if (fileIt != m_fileCache.cend())
return fileIt.value(); return fileIt.value();
QStringList hits;
for (const FileName &f : m_allQrcFiles) { for (const FileName &f : m_allQrcFiles) {
QrcParser::Ptr &qrcParser = m_parserCache[f]; QrcParser::Ptr &qrcParser = m_parserCache[f];
if (!qrcParser) if (!qrcParser)
qrcParser = QrcParser::parseQrcFile(f.toString(), QString()); qrcParser = QrcParser::parseQrcFile(f.toString(), QString());
if (!qrcParser->isValid()) if (!qrcParser->isValid())
continue; continue;
QStringList hits;
qrcParser->collectFilesAtPath(QrcParser::normalizedQrcFilePath(fileUrl.toString()), &hits); qrcParser->collectFilesAtPath(QrcParser::normalizedQrcFilePath(fileUrl.toString()), &hits);
result = transform(hits, [](const QString &fp) { return FileName::fromString(fp); });
} }
hits.removeDuplicates();
const FileNameList result = transform(hits, &FileName::fromString);
m_fileCache.insert(fileUrl, result); m_fileCache.insert(fileUrl, result);
return result; return result;
} }