forked from qt-creator/qt-creator
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user