Commit 32d795f2 authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by hjk

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: default avatarhjk <hjk121@nokiamail.com>
parent 35e22754
......@@ -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
......
......@@ -433,7 +433,7 @@ public:
private:
void allIncludesForDocument_helper(const QString &fileName, QSet<QString> &result) const;
mutable QSharedPointer<DependencyTable> m_deps;
mutable DependencyTable m_deps;
Base _documents;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment