LanguageClient: Avoid crashes when language client is invalid

This can occur in situations such as clangd crashing. A similar guard is
used in the perform() function, but can still crash in cancel() or
handleSignatureResponse() if the client is destroyed beforehand.

Fixes: QTCREATORBUG-27096
Change-Id: Ib33d306c5411bc31bc13de399e6c2ad0a89462f4
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Aaron Barany
2022-05-24 15:30:20 -07:00
parent 255f7f836f
commit 449334e419

View File

@@ -103,6 +103,7 @@ IAssistProposal *FunctionHintProcessor::perform(const AssistInterface *interface
void FunctionHintProcessor::cancel()
{
QTC_ASSERT(m_client, return);
if (running()) {
m_client->cancelRequest(m_currentRequest.value());
m_client->removeAssistProcessor(this);
@@ -112,6 +113,7 @@ void FunctionHintProcessor::cancel()
void FunctionHintProcessor::handleSignatureResponse(const SignatureHelpRequest::Response &response)
{
QTC_ASSERT(m_client, setAsyncProposalAvailable(nullptr); return);
m_currentRequest.reset();
if (auto error = response.error())
m_client->log(error.value());