forked from qt-creator/qt-creator
CodeAssist: Fix leaking proposal model
The model is not owned by the proposal.
For corner cases, we leaked here already for ages. Starting with
commit fab4dd068e
CodeAssist: Fix auto completion if function signature is shown
leaks happened also for a hot path: code completion results that does
not match any so far typed prefix. Due to auto completion turned on,
this triggers frequently when typing text.
Task-number: QTCREATORBUG-17752
Task-number: QTCREATORBUG-18326
Change-Id: I9df177723b31cf3df36e73ef1e7920d9aa5e16e5
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -285,6 +285,8 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
|
|||||||
if (!newProposal)
|
if (!newProposal)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// TODO: The proposal should own the model until someone takes it explicitly away.
|
||||||
|
QScopedPointer<IAssistProposalModel> proposalCandidateModel(newProposal->model());
|
||||||
QScopedPointer<IAssistProposal> proposalCandidate(newProposal);
|
QScopedPointer<IAssistProposal> proposalCandidate(newProposal);
|
||||||
|
|
||||||
bool destroyCurrentContext = false;
|
bool destroyCurrentContext = false;
|
||||||
@@ -336,7 +338,7 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
|
|||||||
m_proposalWidget->setReason(reason);
|
m_proposalWidget->setReason(reason);
|
||||||
m_proposalWidget->setKind(m_assistKind);
|
m_proposalWidget->setKind(m_assistKind);
|
||||||
m_proposalWidget->setUnderlyingWidget(m_editorWidget);
|
m_proposalWidget->setUnderlyingWidget(m_editorWidget);
|
||||||
m_proposalWidget->setModel(m_proposal->model());
|
m_proposalWidget->setModel(proposalCandidateModel.take());
|
||||||
m_proposalWidget->setDisplayRect(m_editorWidget->cursorRect(basePosition));
|
m_proposalWidget->setDisplayRect(m_editorWidget->cursorRect(basePosition));
|
||||||
m_proposalWidget->setIsSynchronized(!m_receivedContentWhileWaiting);
|
m_proposalWidget->setIsSynchronized(!m_receivedContentWhileWaiting);
|
||||||
m_proposalWidget->showProposal(prefix);
|
m_proposalWidget->showProposal(prefix);
|
||||||
|
|||||||
Reference in New Issue
Block a user