OSDN Git Service

Code assist: Fix memory leak in completion
authorLeandro Melo <leandro.melo@nokia.com>
Wed, 7 Sep 2011 12:02:31 +0000 (14:02 +0200)
committerLeandro T. C. Melo <leandro.melo@nokia.com>
Wed, 7 Sep 2011 12:42:16 +0000 (14:42 +0200)
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>
src/plugins/cpptools/cppcompletionassist.cpp
src/plugins/texteditor/codeassist/runner.cpp

index 6409758..c158561 100644 (file)
@@ -776,6 +776,7 @@ IAssistProposal *CppCompletionAssistProcessor::createContentProposal()
                 }
             }
         } else {
+            delete *it;
             it = m_completions.erase(it);
         }
     }
index a6afedc..eaabb5f 100644 (file)
@@ -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)