forked from qt-creator/qt-creator
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:
@@ -45,17 +45,6 @@ CppTodoItemsScanner::CppTodoItemsScanner(const KeywordList &keywordList, QObject
|
|||||||
SLOT(documentUpdated(CPlusPlus::Document::Ptr)), Qt::DirectConnection);
|
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()
|
void CppTodoItemsScanner::keywordListChanged()
|
||||||
{
|
{
|
||||||
// We need to rescan everything known to the code model
|
// We need to rescan everything known to the code model
|
||||||
@@ -72,7 +61,8 @@ void CppTodoItemsScanner::keywordListChanged()
|
|||||||
|
|
||||||
void CppTodoItemsScanner::documentUpdated(CPlusPlus::Document::Ptr doc)
|
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);
|
processDocument(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ public:
|
|||||||
explicit CppTodoItemsScanner(const KeywordList &keywordList, QObject *parent = 0);
|
explicit CppTodoItemsScanner(const KeywordList &keywordList, QObject *parent = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool shouldProcessFile(const QString &fileName);
|
|
||||||
void keywordListChanged();
|
void keywordListChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
Reference in New Issue
Block a user