CppTools: Avoid inserting invalid entries into cache

...of resolved files.

This is an issue when first a misconfigured project (missing include
paths) is indexed. E.g. then <QtTest> resolves to "", which is inserted
into the cache. Resolving the same header for subsequent projects has
returned the empty string although their header paths were correct.

This led to wrong includes of documents from the global snapshot.

Task-number: QTCREATORBUG-15736
Change-Id: Ia3e3a06775a50dd75bc62a46d674c7b46a1c5965
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2016-02-16 16:01:26 +01:00
parent d36716ae14
commit 4795059703

View File

@@ -245,7 +245,8 @@ QString CppSourceProcessor::resolveFile(const QString &fileName, IncludeType typ
if (it != m_fileNameCache.constEnd())
return it.value();
const QString fn = resolveFile_helper(fileName, type);
m_fileNameCache.insert(fileName, fn);
if (!fn.isEmpty())
m_fileNameCache.insert(fileName, fn);
return fn;
}