clangd: Assert on generating tooltip for deleted client

Text marks for diagnostics should be deleted when the client dies. If
they somehow survive assert when creating a tooltip for those text
marks.

Task-number: QTCREATORBUG-26585
Change-Id: Iaebf0d2aba66d2a6c250f8dad7856ef03b1dcacd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2021-12-07 13:26:57 +01:00
parent a4c2f2fb8c
commit 2405ccb271

View File

@@ -395,10 +395,14 @@ ClangdTextMark::ClangdTextMark(const FilePath &filePath,
bool ClangdTextMark::addToolTipContent(QLayout *target) const
{
const auto canApplyFixIt = [c = m_client, diag = m_lspDiagnostic, fp = fileName()] {
return c && c->reachable() && c->hasDiagnostic(DocumentUri::fromFilePath(fp), diag);
return QTC_GUARD(c) && c->reachable()
&& c->hasDiagnostic(DocumentUri::fromFilePath(fp), diag);
};
const QString clientName = QTC_GUARD(m_client) ? m_client->name() : "clangd [unknown]";
target->addWidget(ClangDiagnosticWidget::createWidget({m_diagnostic},
ClangDiagnosticWidget::ToolTip, canApplyFixIt, m_client ? m_client->name() : "clangd"));
ClangDiagnosticWidget::ToolTip,
canApplyFixIt,
clientName));
return true;
}