Editor: delete the processor that proposes a result

Not the currently active one.

Change-Id: Ia0e146e61c07564107ca5a3ec6b5b2d65967f572
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2020-05-14 08:18:32 +02:00
parent 8f5109b6ee
commit 738726d656

View File

@@ -252,18 +252,18 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
break; break;
} }
case IAssistProvider::Asynchronous: { case IAssistProvider::Asynchronous: {
processor->setAsyncCompletionAvailableHandler([this, reason](IAssistProposal *newProposal) { processor->setAsyncCompletionAvailableHandler([this, reason, processor](IAssistProposal *newProposal) {
// do not delete this processor directly since this function is called from within the processor // do not delete this processor directly since this function is called from within the processor
QTimer::singleShot(0, [processor = m_asyncProcessor]() { delete processor; }); QTimer::singleShot(0, [processor]() { delete processor; });
if (m_asyncProcessor && m_asyncProcessor->needsRestart() && m_receivedContentWhileWaiting) { if (processor != m_asyncProcessor)
return;
invalidateCurrentRequestData();
if (processor && processor->needsRestart() && m_receivedContentWhileWaiting) {
delete newProposal; delete newProposal;
m_receivedContentWhileWaiting = false; m_receivedContentWhileWaiting = false;
invalidateCurrentRequestData();
requestProposal(reason, m_assistKind, m_requestProvider); requestProposal(reason, m_assistKind, m_requestProvider);
} else { } else {
invalidateCurrentRequestData();
displayProposal(newProposal, reason); displayProposal(newProposal, reason);
emit q->finished(); emit q->finished();
} }
}); });
@@ -275,6 +275,7 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
} else if (!processor->running()) { } else if (!processor->running()) {
delete processor; delete processor;
} else { // ...async request was triggered } else { // ...async request was triggered
QTC_CHECK(!m_asyncProcessor);
m_asyncProcessor = processor; m_asyncProcessor = processor;
} }