Clang: Fix memory leak on completion

Leak happened if the user triggered the completion again, before the
results for the first completion arrived.

Side note: This is one more reason for using smart pointers to manage
code assist objects.

Change-Id: I582d364286ca47f8622383f3365ad4e5933eb2df
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-07-29 10:58:34 +02:00
parent 5145fc8509
commit 6bb2aa6ba1

View File

@@ -34,6 +34,7 @@
#include "iassistprocessor.h"
#include "textdocument.h"
#include "iassistproposal.h"
#include "iassistproposalmodel.h"
#include "iassistproposalwidget.h"
#include "assistinterface.h"
#include "assistproposalitem.h"
@@ -263,8 +264,11 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
case IAssistProvider::Asynchronous: {
processor->setAsyncCompletionAvailableHandler(
[this, processor, reason](IAssistProposal *newProposal){
if (m_asyncProcessor != processor)
if (m_asyncProcessor != processor) {
delete newProposal->model();
delete newProposal;
return;
}
invalidateCurrentRequestData();
QTC_CHECK(newProposal);