TextEditor: Always destroy old context when displaying new proposal

This makes sure that the old proposal widget is disconnected from the
finalizeProposal slot and thus prevents resetting the currently shown
proposal.

Change-Id: I80d58d9a04831d464bea69697568359990ac5260
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2020-10-23 10:49:37 +02:00
parent 4d8cd5fa03
commit 859d2edbb5

View File

@@ -305,23 +305,17 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
// TODO: The proposal should own the model until someone takes it explicitly away.
QScopedPointer<IAssistProposal> proposalCandidate(newProposal);
bool destroyCurrentContext = false;
if (isDisplayingProposal()) {
if (!m_proposal->isFragile())
return;
destroyCurrentContext = true;
}
if (isDisplayingProposal() && !m_proposal->isFragile())
return;
int basePosition = proposalCandidate->basePosition();
if (m_editorWidget->position() < basePosition) {
if (destroyCurrentContext)
destroyContext();
destroyContext();
return;
}
if (m_abortedBasePosition == basePosition && reason != ExplicitlyInvoked) {
if (destroyCurrentContext)
destroyContext();
destroyContext();
return;
}
@@ -333,8 +327,7 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR
return;
}
if (destroyCurrentContext)
destroyContext();
destroyContext();
clearAbortedPosition();
m_proposal.reset(proposalCandidate.take());