summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/cpptools')
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp41
-rw-r--r--src/plugins/cpptools/cppmodelmanager.h7
-rw-r--r--src/plugins/cpptools/cppmodelmanagerinterface.h6
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.cpp6
4 files changed, 57 insertions, 3 deletions
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index 5cae6bdeaf..6a49051840 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -595,6 +595,8 @@ Document::Ptr CppPreprocessor::switchDocument(Document::Ptr doc)
void CppTools::CppModelManagerInterface::updateModifiedSourceFiles()
{
+ if (isIndexing())
+ return;
const Snapshot snapshot = this->snapshot();
QStringList sourceFiles;
@@ -630,7 +632,8 @@ CppTools::CppModelManagerInterface *CppTools::CppModelManagerInterface::instance
*/
CppModelManager::CppModelManager(QObject *parent)
- : CppModelManagerInterface(parent)
+ : CppModelManagerInterface(parent),
+ m_indexing(false)
{
m_findReferences = new CppFindReferences(this);
@@ -675,6 +678,11 @@ CppModelManager::CppModelManager(QObject *parent)
connect(m_core->editorManager(), SIGNAL(editorAboutToClose(Core::IEditor *)),
this, SLOT(editorAboutToClose(Core::IEditor *)));
+
+ connect(m_core->progressManager(), SIGNAL(taskStarted(QString)),
+ this, SLOT(onTaskStarted(QString)));
+ connect(m_core->progressManager(), SIGNAL(allTasksFinished(QString)),
+ this, SLOT(onAllTasksFinished(QString)));
}
CppModelManager::~CppModelManager()
@@ -871,7 +879,7 @@ QStringList CppModelManager::includesInPath(const QString &path) const
QFuture<void> CppModelManager::refreshSourceFiles(const QStringList &sourceFiles)
{
- if (! sourceFiles.isEmpty() && qgetenv("QTCREATOR_NO_CODE_INDEXER").isNull()) {
+ if (!m_indexing && !sourceFiles.isEmpty() && qgetenv("QTCREATOR_NO_CODE_INDEXER").isNull()) {
const QMap<QString, QString> workingCopy = buildWorkingCopyList();
CppPreprocessor *preproc = new CppPreprocessor(this);
@@ -897,7 +905,7 @@ QFuture<void> CppModelManager::refreshSourceFiles(const QStringList &sourceFiles
m_synchronizer.addFuture(result);
- if (sourceFiles.count() > 1) {
+ if (sourceFiles.count() > 1) {
m_core->progressManager()->addTask(result, tr("Indexing"),
CppTools::Constants::TASK_INDEX,
Core::ProgressManager::CloseOnSuccess);
@@ -1391,4 +1399,31 @@ void CppModelManager::GC()
protectSnapshot.unlock();
}
+bool CppModelManager::isIndexing() const
+{
+ return m_indexing;
+}
+
+void CppModelManager::setIndexing(bool v)
+{
+ if (m_indexing == v)
+ return;
+ m_indexing = v;
+ if (v) {
+ emit indexingStarted();
+ } else {
+ emit indexingFinished();
+ }
+}
+
+void CppModelManager::onTaskStarted(const QString &type)
+{
+ if (type == QLatin1String(CppTools::Constants::TASK_INDEX))
+ setIndexing(true);
+}
+void CppModelManager::onAllTasksFinished(const QString &type)
+{
+ if (type == QLatin1String(CppTools::Constants::TASK_INDEX))
+ setIndexing(false);
+}
diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h
index 4222ccab6b..ca13b44a24 100644
--- a/src/plugins/cpptools/cppmodelmanager.h
+++ b/src/plugins/cpptools/cppmodelmanager.h
@@ -111,6 +111,8 @@ public:
void setHeaderSuffixes(const QStringList &suffixes)
{ m_headerSuffixes = suffixes; }
+ virtual bool isIndexing() const;
+
Q_SIGNALS:
void projectPathChanged(const QString &projectPath);
@@ -129,6 +131,8 @@ private Q_SLOTS:
void onProjectAdded(ProjectExplorer::Project *project);
void postEditorUpdate();
void updateEditorSelections();
+ void onTaskStarted(const QString &type);
+ void onAllTasksFinished(const QString &type);
private:
QMap<QString, QString> buildWorkingCopyList();
@@ -175,10 +179,13 @@ private:
CppPreprocessor *preproc,
QStringList files);
+ void setIndexing(bool);
+
private:
Core::ICore *m_core;
CPlusPlus::Snapshot m_snapshot;
+ bool m_indexing;
// cache
bool m_dirty;
QStringList m_projectFiles;
diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.h b/src/plugins/cpptools/cppmodelmanagerinterface.h
index 1976df75ea..1ec38abe30 100644
--- a/src/plugins/cpptools/cppmodelmanagerinterface.h
+++ b/src/plugins/cpptools/cppmodelmanagerinterface.h
@@ -102,6 +102,12 @@ public:
virtual void renameUsages(CPlusPlus::Symbol *symbol) = 0;
virtual void findUsages(CPlusPlus::Symbol *symbol) = 0;
+ virtual bool isIndexing() const = 0;
+
+signals:
+ void indexingStarted();
+ void indexingFinished();
+
public Q_SLOTS:
void updateModifiedSourceFiles();
virtual void updateSourceFiles(const QStringList &sourceFiles) = 0;
diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp
index bbc894390c..d321b7c39b 100644
--- a/src/plugins/cpptools/cpptoolsplugin.cpp
+++ b/src/plugins/cpptools/cpptoolsplugin.cpp
@@ -47,6 +47,7 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
+#include <coreplugin/vcsmanager.h>
#include <cppeditor/cppeditorconstants.h>
#include <QtCore/QtConcurrentRun>
@@ -97,6 +98,11 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
// Objects
m_modelManager = new CppModelManager(this);
+ Core::VCSManager *vcsManager = core->vcsManager();
+ connect(vcsManager, SIGNAL(repositoryChanged(QString)),
+ m_modelManager, SLOT(updateModifiedSourceFiles()));
+ connect(vcsManager, SIGNAL(filesChanged(QStringList)),
+ m_modelManager, SLOT(updateModifiedSourceFiles()));
addAutoReleasedObject(m_modelManager);
m_completion = new CppCodeCompletion(m_modelManager);