forked from qt-creator/qt-creator
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:
@@ -103,6 +103,7 @@ IAssistProposal *FunctionHintProcessor::perform(const AssistInterface *interface
|
|||||||
|
|
||||||
void FunctionHintProcessor::cancel()
|
void FunctionHintProcessor::cancel()
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(m_client, return);
|
||||||
if (running()) {
|
if (running()) {
|
||||||
m_client->cancelRequest(m_currentRequest.value());
|
m_client->cancelRequest(m_currentRequest.value());
|
||||||
m_client->removeAssistProcessor(this);
|
m_client->removeAssistProcessor(this);
|
||||||
@@ -112,6 +113,7 @@ void FunctionHintProcessor::cancel()
|
|||||||
|
|
||||||
void FunctionHintProcessor::handleSignatureResponse(const SignatureHelpRequest::Response &response)
|
void FunctionHintProcessor::handleSignatureResponse(const SignatureHelpRequest::Response &response)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(m_client, setAsyncProposalAvailable(nullptr); return);
|
||||||
m_currentRequest.reset();
|
m_currentRequest.reset();
|
||||||
if (auto error = response.error())
|
if (auto error = response.error())
|
||||||
m_client->log(error.value());
|
m_client->log(error.value());
|
||||||
|
Reference in New Issue
Block a user