CodeAssistant: Avoid using sender()

Change-Id: I8483b368ebf5dca684d817390e1138362bf11d6f
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-07-20 19:03:10 +02:00
parent 1697f604ed
commit bc8ebd3bc7

View File

@@ -240,10 +240,10 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
m_requestRunner = new ProcessorRunner; m_requestRunner = new ProcessorRunner;
m_runnerConnection = connect(m_requestRunner, &ProcessorRunner::finished, m_runnerConnection = connect(m_requestRunner, &ProcessorRunner::finished,
this, [this, reason](){ this, [this, reason, sender = m_requestRunner] {
// Since the request runner is a different thread, there's still a gap in which the // Since the request runner is a different thread, there's still a gap in which the
// queued signal could be processed after an invalidation of the current request. // queued signal could be processed after an invalidation of the current request.
if (!m_requestRunner || m_requestRunner != sender()) if (!m_requestRunner || m_requestRunner != sender)
return; return;
IAssistProposal *proposal = m_requestRunner->proposal(); IAssistProposal *proposal = m_requestRunner->proposal();
@@ -264,7 +264,7 @@ void CodeAssistantPrivate::requestProposal(AssistReason reason,
IAssistProposal *newProposal) { IAssistProposal *newProposal) {
if (!processor->running()) { if (!processor->running()) {
// 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
QMetaObject::invokeMethod(QCoreApplication::instance(), [processor]() { QMetaObject::invokeMethod(QCoreApplication::instance(), [processor] {
delete processor; delete processor;
}, Qt::QueuedConnection); }, Qt::QueuedConnection);
} }