From 085949bbae83f01f1e6abada7d326c99d7851e65 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 13 Oct 2023 10:42:30 +0200 Subject: [PATCH] LanguageClient: do not assert on sending messages to a dying client Fixes: QTCREATORBUG-29747 Change-Id: I14067695425d74eaeaa255b370ebf4106c0ac591 Reviewed-by: Reviewed-by: Jarek Kobus --- src/plugins/languageclient/client.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index 1d93f869540..e6ee9cf6d18 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -697,6 +697,12 @@ void Client::sendMessage(const JsonRpcMessage &message, SendDocUpdates sendUpdat Schedule semanticTokensSchedule) { QTC_ASSERT(d->m_clientInterface, return); + if (d->m_state == Shutdown || d->m_state == ShutdownRequested) { + auto key = message.toJsonObject().contains(methodKey) ? QString(methodKey) : QString(idKey); + const QString method = message.toJsonObject()[key].toString(); + qCDebug(LOGLSPCLIENT) << "Ignoring message " << method << " because client is shutting down"; + return; + } QTC_ASSERT(d->m_state == Initialized, return); if (sendUpdates == SendDocUpdates::Send) d->sendPostponedDocumentUpdates(semanticTokensSchedule);