From 859d2edbb5f4edffd5e041967d2f630b059ad829 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 23 Oct 2020 10:49:37 +0200 Subject: [PATCH] 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 Reviewed-by: Christian Kandeler --- .../texteditor/codeassist/codeassistant.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/plugins/texteditor/codeassist/codeassistant.cpp b/src/plugins/texteditor/codeassist/codeassistant.cpp index 05f3c8ae17b..317d5a132b7 100644 --- a/src/plugins/texteditor/codeassist/codeassistant.cpp +++ b/src/plugins/texteditor/codeassist/codeassistant.cpp @@ -305,23 +305,17 @@ void CodeAssistantPrivate::displayProposal(IAssistProposal *newProposal, AssistR // TODO: The proposal should own the model until someone takes it explicitly away. QScopedPointer 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());