forked from qt-creator/qt-creator
		
	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>
This commit is contained in:
		
				
					committed by
					
						 Nikolai Kosjar
						Nikolai Kosjar
					
				
			
			
				
	
			
			
			
						parent
						
							d58da4bd7e
						
					
				
				
					commit
					566be0995d
				
			| @@ -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 ¯o, 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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user