Commit ecacaab7 authored by Erik Verbruggen's avatar Erik Verbruggen Committed by Nikolai Kosjar

C++: model-manager clean-ups.

Change-Id: I59fdb898e270af0fcc18e79ae922e119504ef10e
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 0c27b276
......@@ -679,13 +679,13 @@ CppModelManager::~CppModelManager()
Snapshot CppModelManager::snapshot() const
{
QMutexLocker locker(&m_protectSnapshot);
QMutexLocker locker(&m_snapshotMutex);
return m_snapshot;
}
Document::Ptr CppModelManager::document(const QString &fileName) const
{
QMutexLocker locker(&m_protectSnapshot);
QMutexLocker locker(&m_snapshotMutex);
return m_snapshot.document(fileName);
}
......@@ -694,7 +694,7 @@ Document::Ptr CppModelManager::document(const QString &fileName) const
/// \returns true if successful, false if the new document is out-dated.
bool CppModelManager::replaceDocument(Document::Ptr newDoc)
{
QMutexLocker locker(&m_protectSnapshot);
QMutexLocker locker(&m_snapshotMutex);
Document::Ptr previous = m_snapshot.document(newDoc->fileName());
if (previous && (newDoc->revision() != 0 && newDoc->revision() < previous->revision()))
......@@ -707,7 +707,7 @@ bool CppModelManager::replaceDocument(Document::Ptr newDoc)
void CppModelManager::ensureUpdated()
{
QMutexLocker locker(&m_mutex);
QMutexLocker locker(&m_projectMutex);
if (! m_dirty)
return;
......@@ -899,7 +899,7 @@ void CppModelManager::renameMacroUsages(const CPlusPlus::Macro &macro, const QSt
void CppModelManager::replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot)
{
QMutexLocker snapshotLocker(&m_protectSnapshot);
QMutexLocker snapshotLocker(&m_snapshotMutex);
m_snapshot = newSnapshot;
}
......@@ -949,14 +949,14 @@ QFuture<void> CppModelManager::updateSourceFiles(const QStringList &sourceFiles)
QList<CppModelManager::ProjectInfo> CppModelManager::projectInfos() const
{
QMutexLocker locker(&m_mutex);
QMutexLocker locker(&m_projectMutex);
return m_projects.values();
}
CppModelManager::ProjectInfo CppModelManager::projectInfo(ProjectExplorer::Project *project) const
{
QMutexLocker locker(&m_mutex);
QMutexLocker locker(&m_projectMutex);
return m_projects.value(project, ProjectInfo(project));
}
......@@ -964,7 +964,7 @@ CppModelManager::ProjectInfo CppModelManager::projectInfo(ProjectExplorer::Proje
void CppModelManager::updateProjectInfo(const ProjectInfo &pinfo)
{
{ // only hold the mutex for a limited scope, so the dumping afterwards can aquire it without deadlocking.
QMutexLocker locker(&m_mutex);
QMutexLocker locker(&m_projectMutex);
if (! pinfo.isValid())
return;
......@@ -1041,14 +1041,14 @@ void CppModelManager::emitDocumentUpdated(Document::Ptr doc)
void CppModelManager::onProjectAdded(ProjectExplorer::Project *)
{
QMutexLocker locker(&m_mutex);
QMutexLocker locker(&m_projectMutex);
m_dirty = true;
}
void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
{
do {
QMutexLocker locker(&m_mutex);
QMutexLocker locker(&m_projectMutex);
m_dirty = true;
m_projects.remove(project);
} while (0);
......@@ -1061,7 +1061,7 @@ void CppModelManager::onAboutToUnloadSession()
if (Core::ProgressManager *pm = Core::ICore::progressManager())
pm->cancelTasks(QLatin1String(CppTools::Constants::TASK_INDEX));
do {
QMutexLocker locker(&m_mutex);
QMutexLocker locker(&m_projectMutex);
m_projects.clear();
m_dirty = true;
} while (0);
......
......@@ -42,20 +42,13 @@
#include <QHash>
#include <QMutex>
#include <QTimer>
#include <QTextEdit> // for QTextEdit::ExtraSelection
namespace Core { class IEditor; }
namespace TextEditor {
class ITextEditor;
class BaseTextEditorWidget;
} // namespace TextEditor
namespace ProjectExplorer { class ProjectExplorerPlugin; }
namespace CPlusPlus { class ParseManager; }
namespace CppTools {
class CppCompletionSupportFactory;
......@@ -64,7 +57,6 @@ class CppHighlightingSupportFactory;
namespace Internal {
class CppPreprocessor;
class CppFindReferences;
class CPPTOOLS_EXPORT CppModelManager : public CppTools::CppModelManagerInterface
......@@ -149,8 +141,6 @@ public:
}
Q_SIGNALS:
void projectPathChanged(const QString &projectPath);
void aboutToRemoveFiles(const QStringList &files);
public Q_SLOTS:
......@@ -181,10 +171,17 @@ private:
static CppModelManager *m_modelManagerInstance;
private:
// snapshot
mutable QMutex m_snapshotMutex;
CPlusPlus::Snapshot m_snapshot;
bool m_enableGC;
// cache
// project integration
mutable QMutex m_projectMutex;
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
QMap<QString, QList<CppTools::ProjectPart::Ptr> > m_srcToProjectPart;
// cached/calculated from the projects and/or their project-parts
bool m_dirty;
QStringList m_projectFiles;
QStringList m_includePaths;
......@@ -197,17 +194,9 @@ private:
QSet<AbstractEditorSupport *> m_addtionalEditorSupport;
// project integration
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
mutable QMutex m_mutex;
mutable QMutex m_protectSnapshot;
CppFindReferences *m_findReferences;
bool m_indexerEnabled;
QMap<QString, QList<CppTools::ProjectPart::Ptr> > m_srcToProjectPart;
CppCompletionAssistProvider *m_completionAssistProvider;
CppCompletionAssistProvider *m_completionFallback;
CppHighlightingSupportFactory *m_highlightingFactory;
......
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