From 449334e4199e110e5d1994c797df6130f9ea4597 Mon Sep 17 00:00:00 2001 From: Aaron Barany Date: Tue, 24 May 2022 15:30:20 -0700 Subject: [PATCH] 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 --- src/plugins/languageclient/languageclientfunctionhint.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/languageclient/languageclientfunctionhint.cpp b/src/plugins/languageclient/languageclientfunctionhint.cpp index 9c33b632314..708fc399228 100644 --- a/src/plugins/languageclient/languageclientfunctionhint.cpp +++ b/src/plugins/languageclient/languageclientfunctionhint.cpp @@ -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());