C++: Do not share dependency table when copying a Snapshot

There are multiple situations were the snapshot is copied and
access/modifications to the dependency table data is made in other
threads, e.g.:

    * FindUsages called by ProcessFile
    * findReferences() in cppuseselectionsupdater.cpp
    * CppModelManager::projectPartFromDependencies() (clang path)

Change-Id: Ided1c5350f339c5bc960b87b32c78ccc21fa61f6
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Nikolai Kosjar
2014-10-06 14:24:13 +02:00
committed by hjk
parent 35e22754f7
commit 32d795f2b6
2 changed files with 5 additions and 6 deletions

View File

@@ -715,7 +715,6 @@ bool Document::DiagnosticMessage::operator!=(const Document::DiagnosticMessage &
}
Snapshot::Snapshot()
: m_deps(new DependencyTable)
{
}
@@ -752,7 +751,7 @@ void Snapshot::insert(Document::Ptr doc)
{
if (doc) {
_documents.insert(doc->fileName(), doc);
m_deps->files.clear(); // Will trigger re-build when accessed.
m_deps.files.clear(); // Will trigger re-build when accessed.
}
}
@@ -816,13 +815,13 @@ QList<Snapshot::IncludeLocation> Snapshot::includeLocationsOfDocument(const QStr
QStringList Snapshot::filesDependingOn(const QString &fileName) const
{
updateDependencyTable();
return m_deps->filesDependingOn(fileName);
return m_deps.filesDependingOn(fileName);
}
void Snapshot::updateDependencyTable() const
{
if (m_deps->files.isEmpty())
m_deps->build(*this);
if (m_deps.files.isEmpty())
m_deps.build(*this);
}
void Snapshot::allIncludesForDocument_helper(const QString &fileName, QSet<QString> &result) const