Commit bf7486c0 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer

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.
parent d0a2f567
......@@ -48,6 +48,7 @@ TypeOfExpression::TypeOfExpression():
void TypeOfExpression::setDocuments(const QMap<QString, Document::Ptr> &documents)
{
m_documents = documents;
m_lookupContext = LookupContext();
}
QList<TypeOfExpression::Result> TypeOfExpression::operator()(const QString &expression,
......
......@@ -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<QString, Document::Ptr> &documents);
......
......@@ -1027,6 +1027,10 @@ bool CppCodeCompletion::partiallyComplete(const QList<TextEditor::CompletionItem
void CppCodeCompletion::cleanup()
{
m_completions.clear();
// Set empty map in order to avoid referencing old versions of the documents
// until the next completion
typeOfExpression.setDocuments(QMap<QString, Document::Ptr>());
}
int CppCodeCompletion::findStartOfName(const TextEditor::ITextEditor *editor)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment