Todo: Fix thread safety issue in CppTodoItemScanner

Replace the not thread safe Project::files() with the thread safe
CppModelManager::projectPart() to find out whether a file belongs to a
project or not.

Task-number: QTCREATORBUG-12556
Change-Id: Icf443b5b31c818fc15738aa365562db12439d8d7
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Nikolai Kosjar
2014-06-27 10:38:42 -04:00
parent b552cfba1f
commit 919f26a488
2 changed files with 2 additions and 13 deletions

View File

@@ -45,17 +45,6 @@ CppTodoItemsScanner::CppTodoItemsScanner(const KeywordList &keywordList, QObject
SLOT(documentUpdated(CPlusPlus::Document::Ptr)), Qt::DirectConnection);
}
bool CppTodoItemsScanner::shouldProcessFile(const QString &fileName)
{
CppTools::CppModelManagerInterface *modelManager = CppTools::CppModelManagerInterface::instance();
foreach (const CppTools::CppModelManagerInterface::ProjectInfo &info, modelManager->projectInfos())
if (info.project().data()->files(ProjectExplorer::Project::ExcludeGeneratedFiles).contains(fileName))
return true;
return false;
}
void CppTodoItemsScanner::keywordListChanged()
{
// We need to rescan everything known to the code model
@@ -72,7 +61,8 @@ void CppTodoItemsScanner::keywordListChanged()
void CppTodoItemsScanner::documentUpdated(CPlusPlus::Document::Ptr doc)
{
if (shouldProcessFile(doc->fileName()))
CppTools::CppModelManagerInterface *modelManager = CppTools::CppModelManagerInterface::instance();
if (!modelManager->projectPart(doc->fileName()).isEmpty())
processDocument(doc);
}