From bf7486c0118c32fe171cca7e50fd3fb89a5dbe72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Mon, 8 Dec 2008 13:01:54 +0100 Subject: [PATCH] Don't keep around references to old documents The code completion was keeping around references to old documents after the completion finished. This caused documents to stay in memory when unloading projects, up until the next time you used the completion. --- src/libs/cplusplus/TypeOfExpression.cpp | 1 + src/libs/cplusplus/TypeOfExpression.h | 3 +++ src/plugins/cpptools/cppcodecompletion.cpp | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/src/libs/cplusplus/TypeOfExpression.cpp b/src/libs/cplusplus/TypeOfExpression.cpp index 7dd669365fc..487c9f8a469 100644 --- a/src/libs/cplusplus/TypeOfExpression.cpp +++ b/src/libs/cplusplus/TypeOfExpression.cpp @@ -48,6 +48,7 @@ TypeOfExpression::TypeOfExpression(): void TypeOfExpression::setDocuments(const QMap &documents) { m_documents = documents; + m_lookupContext = LookupContext(); } QList TypeOfExpression::operator()(const QString &expression, diff --git a/src/libs/cplusplus/TypeOfExpression.h b/src/libs/cplusplus/TypeOfExpression.h index ecdfac7b290..cd7a23441fd 100644 --- a/src/libs/cplusplus/TypeOfExpression.h +++ b/src/libs/cplusplus/TypeOfExpression.h @@ -54,6 +54,9 @@ public: /** * Sets the documents used to evaluate expressions. Should be set before * calling this functor. + * + * Also clears the lookup context, so can be used to make sure references + * to the documents previously used are removed. */ void setDocuments(const QMap &documents); diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index 47ac5c57678..d24f5a5f81d 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -1027,6 +1027,10 @@ bool CppCodeCompletion::partiallyComplete(const QList()); } int CppCodeCompletion::findStartOfName(const TextEditor::ITextEditor *editor)