diff options
author | Leandro Melo <leandro.melo@nokia.com> | 2011-09-07 14:02:31 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2011-09-12 08:40:05 +0200 |
commit | ad22dc767ce6a01532f11be4e3cf5dee773db405 (patch) | |
tree | 3b8a5d2e31943c3d244c1ed2db8a9b618646ca85 | |
parent | c5694cc5e1959e5c6b9bfbc17c165313dd41118a (diff) |
Code assist: Fix memory leak in completion
One fix is in the runner, which is part of the completion
engine itself. The other is specific for C++.
Task-number: QTCREATORBUG-5947
Change-Id: Ib8fff1eb5adad1ffb2a11da66c50b545e1457df8
Reviewed-on: http://codereview.qt.nokia.com/4355
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
(cherry picked from commit e15443e9523df0e40414b1baf7d8182f641f7f2c)
-rw-r--r-- | src/plugins/cpptools/cppcompletionassist.cpp | 1 | ||||
-rw-r--r-- | src/plugins/texteditor/codeassist/runner.cpp | 6 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp index dddbca6e2f..8a04f940ab 100644 --- a/src/plugins/cpptools/cppcompletionassist.cpp +++ b/src/plugins/cpptools/cppcompletionassist.cpp @@ -775,6 +775,7 @@ IAssistProposal *CppCompletionAssistProcessor::createContentProposal() } } } else { + delete *it; it = m_completions.erase(it); } } diff --git a/src/plugins/texteditor/codeassist/runner.cpp b/src/plugins/texteditor/codeassist/runner.cpp index a6afedcc16..eaabb5f77a 100644 --- a/src/plugins/texteditor/codeassist/runner.cpp +++ b/src/plugins/texteditor/codeassist/runner.cpp @@ -34,6 +34,7 @@ #include "iassistprocessor.h" #include "iassistproposal.h" #include "iassistinterface.h" +#include "iassistproposalmodel.h" using namespace TextEditor; using namespace Internal; @@ -48,8 +49,11 @@ ProcessorRunner::ProcessorRunner() ProcessorRunner::~ProcessorRunner() { delete m_processor; - if (m_discardProposal) + if (m_discardProposal && m_proposal) { + // Proposal doesn't own the model, so we need to delete both. + delete m_proposal->model(); delete m_proposal; + } } void ProcessorRunner::setProcessor(IAssistProcessor *computer) |