summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppfindreferences.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@me.com>2013-10-10 10:26:39 +0200
committerNikolai Kosjar <nikolai.kosjar@digia.com>2013-11-12 09:24:13 +0100
commit566be0995d184cd2c3f99d006ffb7249aeff2e57 (patch)
tree132192382cda9797eb5ea05a792938f1e3148c3b /src/plugins/cpptools/cppfindreferences.cpp
parentd58da4bd7eb4d1f6c983a4a62e5845fe08ede539 (diff)
downloadqt-creator-566be0995d184cd2c3f99d006ffb7249aeff2e57.tar.gz
C++: Release more documents.
- fix memory leak in find-usages - do not retain snapshot in search history - when an editor is invisible for more than 2 minutes, release the backing snapshot Retaining snapshots will retain their documents, and if done for too long, the memory consumption might grow. This is especially the case when switching to a different kit (Qt version): in that case, the new versions of headers will be indexed, while the old ones stay around. Task-number: QTCREATORBUG-5583 Task-number: QTCREATORBUG-7645 Task-number: QTCREATORBUG-9842 Change-Id: I045eda1565e0a3fa702baeffaab9c12662f90289 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/plugins/cpptools/cppfindreferences.cpp')
-rw-r--r--src/plugins/cpptools/cppfindreferences.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp
index 2bd90a6059..a1e9625e85 100644
--- a/src/plugins/cpptools/cppfindreferences.cpp
+++ b/src/plugins/cpptools/cppfindreferences.cpp
@@ -247,8 +247,9 @@ public:
CppFindReferences::CppFindReferences(CppModelManagerInterface *modelManager)
: QObject(modelManager),
- _modelManager(modelManager)
+ m_modelManager(modelManager)
{
+ connect(modelManager, SIGNAL(globalSnapshotChanged()), this, SLOT(flushDependencyTable()));
}
CppFindReferences::~CppFindReferences()
@@ -365,7 +366,7 @@ void CppFindReferences::findAll_helper(Find::SearchResult *search, CPlusPlus::Sy
this, SLOT(openEditor(Find::SearchResultItem)));
Find::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
- const CppModelManagerInterface::WorkingCopy workingCopy = _modelManager->workingCopy();
+ const CppModelManagerInterface::WorkingCopy workingCopy = m_modelManager->workingCopy();
QFuture<Usage> result;
result = QtConcurrent::run(&find_helper, workingCopy, context, this, symbol);
createWatcher(result, search);
@@ -382,7 +383,7 @@ void CppFindReferences::onReplaceButtonClicked(const QString &text,
{
const QStringList fileNames = TextEditor::BaseFileFind::replaceAll(text, items, preserveCase);
if (!fileNames.isEmpty()) {
- _modelManager->updateSourceFiles(fileNames);
+ m_modelManager->updateSourceFiles(fileNames);
Find::SearchResultWindow::instance()->hide();
}
}
@@ -451,7 +452,7 @@ CPlusPlus::Symbol *CppFindReferences::findSymbol(const CppFindReferencesParamete
Document::Ptr newSymbolDocument = snapshot.document(symbolFile);
// document is not parsed and has no bindings yet, do it
- QByteArray source = getSource(newSymbolDocument->fileName(), _modelManager->workingCopy());
+ QByteArray source = getSource(newSymbolDocument->fileName(), m_modelManager->workingCopy());
Document::Ptr doc =
snapshot.preprocessedDocument(source, newSymbolDocument->fileName());
doc->check();
@@ -492,6 +493,7 @@ void CppFindReferences::searchFinished()
if (search)
search->finishSearch(watcher->isCanceled());
m_watchers.remove(watcher);
+ watcher->deleteLater();
}
void CppFindReferences::cancel()
@@ -651,8 +653,8 @@ void CppFindReferences::findMacroUses(const Macro &macro, const QString &replace
connect(search, SIGNAL(cancelled()), this, SLOT(cancel()));
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
- const Snapshot snapshot = _modelManager->snapshot();
- const CppModelManagerInterface::WorkingCopy workingCopy = _modelManager->workingCopy();
+ const Snapshot snapshot = m_modelManager->snapshot();
+ const CppModelManagerInterface::WorkingCopy workingCopy = m_modelManager->workingCopy();
// add the macro definition itself
{
@@ -691,6 +693,13 @@ DependencyTable CppFindReferences::updateDependencyTable(CPlusPlus::Snapshot sna
return newDeps;
}
+void CppFindReferences::flushDependencyTable()
+{
+ QMutexLocker locker(&m_depsLock);
+ Q_UNUSED(locker);
+ m_deps = DependencyTable();
+}
+
DependencyTable CppFindReferences::dependencyTable() const
{
QMutexLocker locker(&m_depsLock);