forked from qt-creator/qt-creator
cache failed parses as well
This commit is contained in:
@@ -95,6 +95,7 @@ static void clearFunctions(ProFileEvaluator::FunctionDefs *defs)
|
|||||||
ProFileCache::~ProFileCache()
|
ProFileCache::~ProFileCache()
|
||||||
{
|
{
|
||||||
foreach (ProFile *pro, parsed_files)
|
foreach (ProFile *pro, parsed_files)
|
||||||
|
if (pro)
|
||||||
pro->deref();
|
pro->deref();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +103,7 @@ void ProFileCache::discardFile(const QString &fileName)
|
|||||||
{
|
{
|
||||||
QHash<QString, ProFile *>::Iterator it = parsed_files.find(fileName);
|
QHash<QString, ProFile *>::Iterator it = parsed_files.find(fileName);
|
||||||
if (it != parsed_files.end()) {
|
if (it != parsed_files.end()) {
|
||||||
|
if (it.value())
|
||||||
it.value()->deref();
|
it.value()->deref();
|
||||||
parsed_files.erase(it);
|
parsed_files.erase(it);
|
||||||
}
|
}
|
||||||
@@ -114,6 +116,7 @@ void ProFileCache::discardFiles(const QString &prefix)
|
|||||||
end = parsed_files.end();
|
end = parsed_files.end();
|
||||||
while (it != end)
|
while (it != end)
|
||||||
if (it.key().startsWith(prefix)) {
|
if (it.key().startsWith(prefix)) {
|
||||||
|
if (it.value())
|
||||||
it.value()->deref();
|
it.value()->deref();
|
||||||
it = parsed_files.erase(it);
|
it = parsed_files.erase(it);
|
||||||
} else {
|
} else {
|
||||||
@@ -121,9 +124,10 @@ void ProFileCache::discardFiles(const QString &prefix)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProFileCache::addFile(ProFile *pro)
|
void ProFileCache::addFile(const QString &fileName, ProFile *pro)
|
||||||
{
|
{
|
||||||
parsed_files[pro->fileName()] = pro;
|
parsed_files[fileName] = pro;
|
||||||
|
if (pro)
|
||||||
pro->ref();
|
pro->ref();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3027,10 +3031,10 @@ ProFile *ProFileEvaluator::Private::parsedProFile(const QString &fileName, bool
|
|||||||
pro = new ProFile(fileName);
|
pro = new ProFile(fileName);
|
||||||
if (!(contents.isNull() ? read(pro) : read(pro, contents))) {
|
if (!(contents.isNull() ? read(pro) : read(pro, contents))) {
|
||||||
delete pro;
|
delete pro;
|
||||||
return 0;
|
pro = 0;
|
||||||
}
|
}
|
||||||
if (m_option->cache && cache)
|
if (m_option->cache && cache)
|
||||||
m_option->cache->addFile(pro);
|
m_option->cache->addFile(fileName, pro);
|
||||||
}
|
}
|
||||||
return pro;
|
return pro;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
ProFileCache() {}
|
ProFileCache() {}
|
||||||
~ProFileCache();
|
~ProFileCache();
|
||||||
|
|
||||||
void addFile(ProFile *pro);
|
void addFile(const QString &fileName, ProFile *pro);
|
||||||
ProFile *getFile(const QString &fileName);
|
ProFile *getFile(const QString &fileName);
|
||||||
|
|
||||||
void discardFile(const QString &fileName);
|
void discardFile(const QString &fileName);
|
||||||
|
|||||||
Reference in New Issue
Block a user