forked from qt-creator/qt-creator
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:
@@ -252,20 +252,20 @@ 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)
|
||||||
delete newProposal;
|
return;
|
||||||
m_receivedContentWhileWaiting = false;
|
invalidateCurrentRequestData();
|
||||||
invalidateCurrentRequestData();
|
if (processor && processor->needsRestart() && m_receivedContentWhileWaiting) {
|
||||||
requestProposal(reason, m_assistKind, m_requestProvider);
|
delete newProposal;
|
||||||
} else {
|
m_receivedContentWhileWaiting = false;
|
||||||
invalidateCurrentRequestData();
|
requestProposal(reason, m_assistKind, m_requestProvider);
|
||||||
displayProposal(newProposal, reason);
|
} else {
|
||||||
|
displayProposal(newProposal, reason);
|
||||||
emit q->finished();
|
emit q->finished();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// If there is a proposal, nothing asynchronous happened...
|
// If there is a proposal, nothing asynchronous happened...
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user