Commit fdaddec7 authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by David Schulz

CppTools: Clean up CppModelManager(Interface)

* Const correctness
* Better variable names
* Sort order of includes and forward declarations
* Comment fixes
* Cosmetic/Whitespace changes

Change-Id: Ieb137266ac7eddedb00c37f8b2cc8677d67e4bdd
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent f0682231
...@@ -128,7 +128,7 @@ CMakeProject::~CMakeProject() ...@@ -128,7 +128,7 @@ CMakeProject::~CMakeProject()
it = m_uiCodeModelSupport.constBegin(); it = m_uiCodeModelSupport.constBegin();
end = m_uiCodeModelSupport.constEnd(); end = m_uiCodeModelSupport.constEnd();
for (; it!=end; ++it) { for (; it!=end; ++it) {
modelManager->removeEditorSupport(it.value()); modelManager->removeExtraEditorSupport(it.value());
delete it.value(); delete it.value();
} }
...@@ -794,7 +794,7 @@ void CMakeProject::createUiCodeModelSupport() ...@@ -794,7 +794,7 @@ void CMakeProject::createUiCodeModelSupport()
// qDebug()<<"adding new codemodelsupport"; // qDebug()<<"adding new codemodelsupport";
QtSupport::UiCodeModelSupport *cms = new QtSupport::UiCodeModelSupport(modelManager, this, uiFile, uiHeaderFilePath); QtSupport::UiCodeModelSupport *cms = new QtSupport::UiCodeModelSupport(modelManager, this, uiFile, uiHeaderFilePath);
m_uiCodeModelSupport.insert(uiFile, cms); m_uiCodeModelSupport.insert(uiFile, cms);
modelManager->addEditorSupport(cms); modelManager->addExtraEditorSupport(cms);
} }
} }
} }
...@@ -803,7 +803,7 @@ void CMakeProject::createUiCodeModelSupport() ...@@ -803,7 +803,7 @@ void CMakeProject::createUiCodeModelSupport()
QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it, end; QMap<QString, QtSupport::UiCodeModelSupport *>::const_iterator it, end;
end = oldCodeModelSupport.constEnd(); end = oldCodeModelSupport.constEnd();
for (it = oldCodeModelSupport.constBegin(); it!=end; ++it) { for (it = oldCodeModelSupport.constBegin(); it!=end; ++it) {
modelManager->removeEditorSupport(it.value()); modelManager->removeExtraEditorSupport(it.value());
delete it.value(); delete it.value();
} }
} }
......
...@@ -561,7 +561,7 @@ CPPEditorWidget::CPPEditorWidget(QWidget *parent) ...@@ -561,7 +561,7 @@ CPPEditorWidget::CPPEditorWidget(QWidget *parent)
CPPEditorWidget::~CPPEditorWidget() CPPEditorWidget::~CPPEditorWidget()
{ {
if (m_modelManager) if (m_modelManager)
m_modelManager->deleteEditorSupport(editor()); m_modelManager->deleteCppEditorSupport(editor());
delete m_completionSupport; delete m_completionSupport;
} }
......
...@@ -28,31 +28,30 @@ ...@@ -28,31 +28,30 @@
****************************************************************************/ ****************************************************************************/
#include "cppmodelmanager.h" #include "cppmodelmanager.h"
#include "cpppreprocessor.h"
#include "cpptoolsconstants.h"
#include "abstracteditorsupport.h"
#include "builtinindexingsupport.h" #include "builtinindexingsupport.h"
#include "cppcompletionassist.h" #include "cppcompletionassist.h"
#include "cppfindreferences.h"
#include "cpphighlightingsupport.h" #include "cpphighlightingsupport.h"
#include "cpphighlightingsupportinternal.h" #include "cpphighlightingsupportinternal.h"
#include "cppindexingsupport.h" #include "cppindexingsupport.h"
#include "abstracteditorsupport.h" #include "cpppreprocessor.h"
#include "cpptoolsconstants.h"
#include "cpptoolseditorsupport.h" #include "cpptoolseditorsupport.h"
#include "cppfindreferences.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/progressmanager.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QCoreApplication> #include <QCoreApplication>
#include <QDebug> #include <QDebug>
#include <QMutexLocker> #include <QMutexLocker>
#include <QTimer>
#include <QTextBlock> #include <QTextBlock>
#include <QTimer>
#if defined(QTCREATOR_WITH_DUMP_AST) && defined(Q_CC_GNU) #if defined(QTCREATOR_WITH_DUMP_AST) && defined(Q_CC_GNU)
#define WITH_AST_DUMP #define WITH_AST_DUMP
...@@ -99,7 +98,7 @@ using namespace CppTools; ...@@ -99,7 +98,7 @@ using namespace CppTools;
using namespace CppTools::Internal; using namespace CppTools::Internal;
using namespace CPlusPlus; using namespace CPlusPlus;
#ifdef WITH_AST_DUMP #ifdef QTCREATOR_WITH_DUMP_AST
#include <cxxabi.h> #include <cxxabi.h>
...@@ -194,41 +193,44 @@ void CppModelManager::updateModifiedSourceFiles() ...@@ -194,41 +193,44 @@ void CppModelManager::updateModifiedSourceFiles()
/*! /*!
\class CppTools::CppModelManager \class CppTools::CppModelManager
\brief The CppModelManager class keeps track of one CppCodeModel instance \brief The CppModelManager keeps tracks of the source files the code model is aware of.
for each project and all the related CppCodeModelPart instances.
The CppModelManager manages the source files in a Snapshot object.
It also takes care of updating the code models when C++ files are The snapshot is updated in case e.g.
modified within Qt Creator. * New files are opened/edited (Editor integration)
* A project manager pushes updated project information (Project integration)
* Files are garbage collected
*/ */
QMutex CppModelManager::m_modelManagerMutex; QMutex CppModelManager::m_instanceMutex;
CppModelManager *CppModelManager::m_modelManagerInstance = 0; CppModelManager *CppModelManager::m_instance = 0;
CppModelManager *CppModelManager::instance() CppModelManager *CppModelManager::instance()
{ {
if (m_modelManagerInstance) if (m_instance)
return m_modelManagerInstance; return m_instance;
QMutexLocker locker(&m_modelManagerMutex);
if (!m_modelManagerInstance) QMutexLocker locker(&m_instanceMutex);
m_modelManagerInstance = new CppModelManager; if (!m_instance)
return m_modelManagerInstance; m_instance = new CppModelManager;
return m_instance;
} }
CppModelManager::CppModelManager(QObject *parent) CppModelManager::CppModelManager(QObject *parent)
: CppModelManagerInterface(parent) : CppModelManagerInterface(parent)
, m_enableGC(true)
, m_completionAssistProvider(0) , m_completionAssistProvider(0)
, m_highlightingFactory(0) , m_highlightingFactory(0)
, m_indexingSupporter(0) , m_indexingSupporter(0)
, m_enableGC(true)
{ {
m_findReferences = new CppFindReferences(this); m_findReferences = new CppFindReferences(this);
m_indexerEnabled = qgetenv("QTCREATOR_NO_CODE_INDEXER").isNull(); m_indexerEnabled = qgetenv("QTCREATOR_NO_CODE_INDEXER").isNull();
m_dirty = true; m_dirty = true;
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
ProjectExplorer::ProjectExplorerPlugin::instance();
QTC_ASSERT(pe, return); QTC_ASSERT(pe, return);
ProjectExplorer::SessionManager *session = pe->session(); ProjectExplorer::SessionManager *session = pe->session();
...@@ -306,10 +308,10 @@ void CppModelManager::ensureUpdated() ...@@ -306,10 +308,10 @@ void CppModelManager::ensureUpdated()
QStringList CppModelManager::internalProjectFiles() const QStringList CppModelManager::internalProjectFiles() const
{ {
QStringList files; QStringList files;
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects); QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projectToProjectsInfo);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
ProjectInfo pinfo = it.value(); const ProjectInfo pinfo = it.value();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) { foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
foreach (const ProjectFile &file, part->files) foreach (const ProjectFile &file, part->files)
files += file.path; files += file.path;
...@@ -322,10 +324,10 @@ QStringList CppModelManager::internalProjectFiles() const ...@@ -322,10 +324,10 @@ QStringList CppModelManager::internalProjectFiles() const
QStringList CppModelManager::internalIncludePaths() const QStringList CppModelManager::internalIncludePaths() const
{ {
QStringList includePaths; QStringList includePaths;
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects); QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projectToProjectsInfo);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
ProjectInfo pinfo = it.value(); const ProjectInfo pinfo = it.value();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) foreach (const ProjectPart::Ptr &part, pinfo.projectParts())
foreach (const QString &path, part->includePaths) foreach (const QString &path, part->includePaths)
includePaths.append(CppPreprocessor::cleanPath(path)); includePaths.append(CppPreprocessor::cleanPath(path));
...@@ -337,10 +339,10 @@ QStringList CppModelManager::internalIncludePaths() const ...@@ -337,10 +339,10 @@ QStringList CppModelManager::internalIncludePaths() const
QStringList CppModelManager::internalFrameworkPaths() const QStringList CppModelManager::internalFrameworkPaths() const
{ {
QStringList frameworkPaths; QStringList frameworkPaths;
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects); QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projectToProjectsInfo);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
ProjectInfo pinfo = it.value(); const ProjectInfo pinfo = it.value();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) foreach (const ProjectPart::Ptr &part, pinfo.projectParts())
foreach (const QString &path, part->frameworkPaths) foreach (const QString &path, part->frameworkPaths)
frameworkPaths.append(CppPreprocessor::cleanPath(path)); frameworkPaths.append(CppPreprocessor::cleanPath(path));
...@@ -353,10 +355,10 @@ QByteArray CppModelManager::internalDefinedMacros() const ...@@ -353,10 +355,10 @@ QByteArray CppModelManager::internalDefinedMacros() const
{ {
QByteArray macros; QByteArray macros;
QSet<QByteArray> alreadyIn; QSet<QByteArray> alreadyIn;
QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projects); QMapIterator<ProjectExplorer::Project *, ProjectInfo> it(m_projectToProjectsInfo);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
ProjectInfo pinfo = it.value(); const ProjectInfo pinfo = it.value();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) { foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
const QList<QByteArray> defs = part->defines.split('\n'); const QList<QByteArray> defs = part->defines.split('\n');
foreach (const QByteArray &def, defs) { foreach (const QByteArray &def, defs) {
...@@ -375,9 +377,9 @@ QByteArray CppModelManager::internalDefinedMacros() const ...@@ -375,9 +377,9 @@ QByteArray CppModelManager::internalDefinedMacros() const
void CppModelManager::dumpModelManagerConfiguration() void CppModelManager::dumpModelManagerConfiguration()
{ {
// Tons of debug output... // Tons of debug output...
qDebug()<<"========= CppModelManager::dumpModelManagerConfiguration ======"; qDebug() << "========= CppModelManager::dumpModelManagerConfiguration ======";
foreach (const ProjectInfo &pinfo, m_projects) { foreach (const ProjectInfo &pinfo, m_projectToProjectsInfo) {
qDebug()<<" for project:"<< pinfo.project().data()->document()->filePath(); qDebug() << " for project:"<< pinfo.project().data()->document()->filePath();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) { foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
qDebug() << "=== part ==="; qDebug() << "=== part ===";
const char* cVersion; const char* cVersion;
...@@ -425,35 +427,64 @@ void CppModelManager::dumpModelManagerConfiguration() ...@@ -425,35 +427,64 @@ void CppModelManager::dumpModelManagerConfiguration()
qDebug() << inc; qDebug() << inc;
qDebug() << "=== Merged defined macros ==="; qDebug() << "=== Merged defined macros ===";
qDebug() << m_definedMacros; qDebug() << m_definedMacros;
qDebug()<<"========= End of dump ======"; qDebug() << "========= End of dump ======";
} }
void CppModelManager::addEditorSupport(AbstractEditorSupport *editorSupport) void CppModelManager::addExtraEditorSupport(AbstractEditorSupport *editorSupport)
{ {
m_addtionalEditorSupport.insert(editorSupport); m_extraEditorSupports.insert(editorSupport);
} }
void CppModelManager::removeEditorSupport(AbstractEditorSupport *editorSupport) void CppModelManager::removeExtraEditorSupport(AbstractEditorSupport *editorSupport)
{ {
m_addtionalEditorSupport.remove(editorSupport); m_extraEditorSupports.remove(editorSupport);
} }
/// \brief Returns the \c CppEditorSupport for the given text editor. It will /// \brief Returns the \c CppEditorSupport for the given text editor. It will
/// create one when none exists yet. /// create one when none exists yet.
CppEditorSupport *CppModelManager::cppEditorSupport(TextEditor::BaseTextEditor *editor) CppEditorSupport *CppModelManager::cppEditorSupport(TextEditor::BaseTextEditor *textEditor)
{ {
Q_ASSERT(editor); Q_ASSERT(textEditor);
QMutexLocker locker(&m_editorSupportMutex); QMutexLocker locker(&m_cppEditorSupportsMutex);
CppEditorSupport *editorSupport = m_editorSupport.value(editor, 0); CppEditorSupport *editorSupport = m_cppEditorSupports.value(textEditor, 0);
if (!editorSupport) { if (!editorSupport) {
editorSupport = new CppEditorSupport(this, editor); editorSupport = new CppEditorSupport(this, textEditor);
m_editorSupport.insert(editor, editorSupport); m_cppEditorSupports.insert(textEditor, editorSupport);
} }
return editorSupport; return editorSupport;
} }
/// \brief Removes the CppEditorSupport for the closed editor.
void CppModelManager::deleteCppEditorSupport(TextEditor::BaseTextEditor *textEditor)
{
static short numberOfClosedEditors = 0;
QTC_ASSERT(textEditor, return);
if (!isCppEditor(textEditor))
return;
CppEditorSupport *editorSupport;
int numberOfOpenEditors = 0;
{ // Only lock the operations on m_cppEditorSupport
QMutexLocker locker(&m_cppEditorSupportsMutex);
editorSupport = m_cppEditorSupports.value(textEditor, 0);
m_cppEditorSupports.remove(textEditor);
numberOfOpenEditors = m_cppEditorSupports.size();
}
delete editorSupport;
++numberOfClosedEditors;
if (numberOfOpenEditors == 0 || numberOfClosedEditors == 5) {
numberOfClosedEditors = 0;
GC();
}
}
QList<int> CppModelManager::references(CPlusPlus::Symbol *symbol, const LookupContext &context) QList<int> CppModelManager::references(CPlusPlus::Symbol *symbol, const LookupContext &context)
{ {
return m_findReferences->references(symbol, context); return m_findReferences->references(symbol, context);
...@@ -465,7 +496,8 @@ void CppModelManager::findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::Loo ...@@ -465,7 +496,8 @@ void CppModelManager::findUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::Loo
m_findReferences->findUsages(symbol, context); m_findReferences->findUsages(symbol, context);
} }
void CppModelManager::renameUsages(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context, void CppModelManager::renameUsages(CPlusPlus::Symbol *symbol,
const CPlusPlus::LookupContext &context,
const QString &replacement) const QString &replacement)
{ {
if (symbol->identifier()) if (symbol->identifier())
...@@ -490,26 +522,26 @@ void CppModelManager::replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot) ...@@ -490,26 +522,26 @@ void CppModelManager::replaceSnapshot(const CPlusPlus::Snapshot &newSnapshot)
CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList() CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList()
{ {
QList<CppEditorSupport *> supporters; QList<CppEditorSupport *> cppEditorSupports;
{ {
QMutexLocker locker(&m_editorSupportMutex); QMutexLocker locker(&m_cppEditorSupportsMutex);
supporters = m_editorSupport.values(); cppEditorSupports = m_cppEditorSupports.values();
} }
WorkingCopy workingCopy; WorkingCopy workingCopy;
foreach (const CppEditorSupport *editorSupport, supporters) { foreach (const CppEditorSupport *editorSupport, cppEditorSupports) {
workingCopy.insert(editorSupport->fileName(), editorSupport->contents(), workingCopy.insert(editorSupport->fileName(), editorSupport->contents(),
editorSupport->editorRevision()); editorSupport->editorRevision());
} }
QSetIterator<AbstractEditorSupport *> jt(m_addtionalEditorSupport); QSetIterator<AbstractEditorSupport *> it(m_extraEditorSupports);
while (jt.hasNext()) { while (it.hasNext()) {
AbstractEditorSupport *es = jt.next(); AbstractEditorSupport *es = it.next();
workingCopy.insert(es->fileName(), QString::fromUtf8(es->contents())); workingCopy.insert(es->fileName(), QString::fromUtf8(es->contents()));
} }
// add the project configuration file // Add the project configuration file
QByteArray conf(pp_configuration); QByteArray conf(pp_configuration);
conf += definedMacros(); conf += definedMacros();
workingCopy.insert(configurationFileName(), QString::fromLocal8Bit(conf)); workingCopy.insert(configurationFileName(), QString::fromLocal8Bit(conf));
...@@ -536,27 +568,25 @@ QFuture<void> CppModelManager::updateSourceFiles(const QStringList &sourceFiles, ...@@ -536,27 +568,25 @@ QFuture<void> CppModelManager::updateSourceFiles(const QStringList &sourceFiles,
QList<CppModelManager::ProjectInfo> CppModelManager::projectInfos() const QList<CppModelManager::ProjectInfo> CppModelManager::projectInfos() const
{ {
QMutexLocker locker(&m_projectMutex); QMutexLocker locker(&m_projectMutex);
return m_projectToProjectsInfo.values();
return m_projects.values();
} }
CppModelManager::ProjectInfo CppModelManager::projectInfo(ProjectExplorer::Project *project) const CppModelManager::ProjectInfo CppModelManager::projectInfo(ProjectExplorer::Project *project) const
{ {
QMutexLocker locker(&m_projectMutex); QMutexLocker locker(&m_projectMutex);
return m_projectToProjectsInfo.value(project, ProjectInfo(project));
return m_projects.value(project, ProjectInfo(project));
} }
QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &pinfo) QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &pinfo)
{ {
{ // only hold the mutex for a limited scope, so the dumping afterwards can aquire it without deadlocking. if (!pinfo.isValid())
QMutexLocker locker(&m_projectMutex); return QFuture<void>();
if (!pinfo.isValid()) { // Only hold the mutex for a limited scope, so the dumping afterwards does not deadlock.
return QFuture<void>(); QMutexLocker locker(&m_projectMutex);
ProjectExplorer::Project *project = pinfo.project().data(); ProjectExplorer::Project *project = pinfo.project().data();
ProjectInfo oldProjectInfo = m_projects.value(project); ProjectInfo oldProjectInfo = m_projectToProjectsInfo.value(project);
if (oldProjectInfo.isValid()) { if (oldProjectInfo.isValid()) {
if (pinfo.defines() == oldProjectInfo.defines() if (pinfo.defines() == oldProjectInfo.defines()
&& pinfo.includePaths() == oldProjectInfo.includePaths() && pinfo.includePaths() == oldProjectInfo.includePaths()
...@@ -577,14 +607,14 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &pinfo) ...@@ -577,14 +607,14 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &pinfo)
} }
m_snapshot.remove(configurationFileName()); m_snapshot.remove(configurationFileName());
m_projects.insert(project, pinfo); m_projectToProjectsInfo.insert(project, pinfo);
m_dirty = true; m_dirty = true;
m_srcToProjectPart.clear(); m_fileToProjectParts.clear();
foreach (const ProjectInfo &projectInfo, m_projects) { foreach (const ProjectInfo &projectInfo, m_projectToProjectsInfo) {
foreach (const ProjectPart::Ptr &projectPart, projectInfo.projectParts()) { foreach (const ProjectPart::Ptr &projectPart, projectInfo.projectParts()) {
foreach (const ProjectFile &cxxFile, projectPart->files) { foreach (const ProjectFile &cxxFile, projectPart->files) {
m_srcToProjectPart[cxxFile.path].append(projectPart); m_fileToProjectParts[cxxFile.path].append(projectPart);
} }
} }
} }
...@@ -600,15 +630,15 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &pinfo) ...@@ -600,15 +630,15 @@ QFuture<void> CppModelManager::updateProjectInfo(const ProjectInfo &pinfo)
QList<ProjectPart::Ptr> CppModelManager::projectPart(const QString &fileName) const QList<ProjectPart::Ptr> CppModelManager::projectPart(const QString &fileName) const
{ {
QList<ProjectPart::Ptr> parts = m_srcToProjectPart.value(fileName); QList<ProjectPart::Ptr> parts = m_fileToProjectParts.value(fileName);
if (!parts.isEmpty()) if (!parts.isEmpty())
return parts; return parts;
DependencyTable table; DependencyTable table;
table.build(snapshot()); table.build(snapshot());
QStringList deps = table.filesDependingOn(fileName); const QStringList deps = table.filesDependingOn(fileName);
foreach (const QString &dep, deps) { foreach (const QString &dep, deps) {
parts = m_srcToProjectPart.value(dep); parts = m_fileToProjectParts.value(dep);
if (!parts.isEmpty()) if (!parts.isEmpty())
return parts; return parts;
} }
...@@ -616,35 +646,6 @@ QList<ProjectPart::Ptr> CppModelManager::projectPart(const QString &fileName) co ...@@ -616,35 +646,6 @@ QList<ProjectPart::Ptr> CppModelManager::projectPart(const QString &fileName) co
return parts; return parts;
} }
/// \brief Removes the CppEditorSupport for the closed editor.
void CppModelManager::deleteEditorSupport(TextEditor::BaseTextEditor *textEditor)
{
static short numberOfClosedEditors = 0;
QTC_ASSERT(textEditor, return);
if (!isCppEditor(textEditor))
return;
CppEditorSupport *editorSupport;
int numberOfOpenEditors = 0;
{ // only lock the operations on m_editorSupport
QMutexLocker locker(&m_editorSupportMutex);
editorSupport = m_editorSupport.value(textEditor, 0);
m_editorSupport.remove(textEditor);
numberOfOpenEditors = m_editorSupport.size();
}
delete editorSupport;
++numberOfClosedEditors;
if (numberOfOpenEditors == 0 || numberOfClosedEditors == 5) {
numberOfClosedEditors = 0;
GC();
}
}
bool CppModelManager::isCppEditor(Core::IEditor *editor) const bool CppModelManager::isCppEditor(Core::IEditor *editor) const
{ {
return editor->context().contains(ProjectExplorer::Constants::LANG_CXX); return editor->context().contains(ProjectExplorer::Constants::LANG_CXX);
...@@ -667,7 +668,7 @@ void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project) ...@@ -667,7 +668,7 @@ void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
do { do {
QMutexLocker locker(&m_projectMutex); QMutexLocker locker(&m_projectMutex);
m_dirty = true; m_dirty = true;
m_projects.remove(project);