From 66780cf198c0166f04effb301bb4f13a5f864903 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Date: Fri, 26 Feb 2010 12:50:57 +0100 Subject: [PATCH] cache failed parses as well --- src/shared/proparser/profileevaluator.cpp | 20 ++++++++++++-------- src/shared/proparser/profileevaluator.h | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/shared/proparser/profileevaluator.cpp b/src/shared/proparser/profileevaluator.cpp index 4e7fed550a5..4ad78d02e4c 100644 --- a/src/shared/proparser/profileevaluator.cpp +++ b/src/shared/proparser/profileevaluator.cpp @@ -95,14 +95,16 @@ static void clearFunctions(ProFileEvaluator::FunctionDefs *defs) ProFileCache::~ProFileCache() { foreach (ProFile *pro, parsed_files) - pro->deref(); + if (pro) + pro->deref(); } void ProFileCache::discardFile(const QString &fileName) { QHash<QString, ProFile *>::Iterator it = parsed_files.find(fileName); if (it != parsed_files.end()) { - it.value()->deref(); + if (it.value()) + it.value()->deref(); parsed_files.erase(it); } } @@ -114,17 +116,19 @@ void ProFileCache::discardFiles(const QString &prefix) end = parsed_files.end(); while (it != end) if (it.key().startsWith(prefix)) { - it.value()->deref(); + if (it.value()) + it.value()->deref(); it = parsed_files.erase(it); } else { ++it; } } -void ProFileCache::addFile(ProFile *pro) +void ProFileCache::addFile(const QString &fileName, ProFile *pro) { - parsed_files[pro->fileName()] = pro; - pro->ref(); + parsed_files[fileName] = pro; + if (pro) + pro->ref(); } ProFile *ProFileCache::getFile(const QString &fileName) @@ -3027,10 +3031,10 @@ ProFile *ProFileEvaluator::Private::parsedProFile(const QString &fileName, bool pro = new ProFile(fileName); if (!(contents.isNull() ? read(pro) : read(pro, contents))) { delete pro; - return 0; + pro = 0; } if (m_option->cache && cache) - m_option->cache->addFile(pro); + m_option->cache->addFile(fileName, pro); } return pro; } diff --git a/src/shared/proparser/profileevaluator.h b/src/shared/proparser/profileevaluator.h index 8a42975b644..8834d543e8d 100644 --- a/src/shared/proparser/profileevaluator.h +++ b/src/shared/proparser/profileevaluator.h @@ -47,7 +47,7 @@ public: ProFileCache() {} ~ProFileCache(); - void addFile(ProFile *pro); + void addFile(const QString &fileName, ProFile *pro); ProFile *getFile(const QString &fileName); void discardFile(const QString &fileName); -- GitLab