forked from qt-creator/qt-creator
CodeAssistant: do not schedule processor deletion too early
Calling displayProposal might spawn another eventloop that potentially deletes the processor before the async proposal handler finished. Fixes: QTCREATORBUG-28989 Change-Id: I3a8ddb9180cb7737a37ea39dc59d922e83615ed6 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -185,14 +185,7 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
||||
IAssistProcessor *processor = provider->createProcessor(assistInterface.get());
|
||||
processor->setAsyncCompletionAvailableHandler([this, reason, processor](
|
||||
IAssistProposal *newProposal) {
|
||||
if (!processor->running()) {
|
||||
// do not delete this processor directly since this function is called from within the processor
|
||||
QMetaObject::invokeMethod(QCoreApplication::instance(), [processor] {
|
||||
delete processor;
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
if (processor != m_processor)
|
||||
return;
|
||||
if (processor == m_processor) {
|
||||
invalidateCurrentRequestData();
|
||||
if (processor->needsRestart() && m_receivedContentWhileWaiting) {
|
||||
delete newProposal;
|
||||
@@ -205,6 +198,13 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
|
||||
else
|
||||
emit q->finished();
|
||||
}
|
||||
}
|
||||
if (!processor->running()) {
|
||||
// do not delete this processor directly since this function is called from within the processor
|
||||
QMetaObject::invokeMethod(QCoreApplication::instance(), [processor] {
|
||||
delete processor;
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
});
|
||||
|
||||
if (IAssistProposal *newProposal = processor->start(std::move(assistInterface)))
|
||||
|
||||
Reference in New Issue
Block a user