forked from qt-creator/qt-creator
Clangd: clean up text marks after deleting client
This is a blindshot and more a workaround than a fix. Assert and try to cleanup dangling text marks after a client got deleted. In theory those marks should get deleted by the DiagnosticManager but somehow, they are still alive and happy after the client was deleted. Task-number: QTCREATORBUG-26585 Change-Id: I9d5d708db3fbbe30a09d322400d97184fe40a518 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -406,6 +406,11 @@ ClangdTextMark::ClangdTextMark(const FilePath &filePath,
|
||||
ClangDiagnosticManager::addTask(m_diagnostic);
|
||||
}
|
||||
|
||||
m_clientDeleted = QObject::connect(client, &QObject::destroyed, [this] (){
|
||||
QTC_ASSERT_STRING("ClangdClient deleted before TextMark");
|
||||
delete this;
|
||||
});
|
||||
|
||||
// Copy to clipboard action
|
||||
QVector<QAction *> actions;
|
||||
QAction *action = new QAction();
|
||||
@@ -433,6 +438,11 @@ ClangdTextMark::ClangdTextMark(const FilePath &filePath,
|
||||
setActions(actions);
|
||||
}
|
||||
|
||||
ClangdTextMark::~ClangdTextMark()
|
||||
{
|
||||
QObject::disconnect(m_clientDeleted);
|
||||
}
|
||||
|
||||
bool ClangdTextMark::addToolTipContent(QLayout *target) const
|
||||
{
|
||||
const auto canApplyFixIt = [c = m_client, diag = m_lspDiagnostic, fp = fileName()] {
|
||||
|
@@ -73,6 +73,7 @@ public:
|
||||
ClangdTextMark(const ::Utils::FilePath &filePath,
|
||||
const LanguageServerProtocol::Diagnostic &diagnostic,
|
||||
const LanguageClient::Client *client);
|
||||
~ClangdTextMark();
|
||||
|
||||
private:
|
||||
bool addToolTipContent(QLayout *target) const override;
|
||||
@@ -80,6 +81,8 @@ private:
|
||||
const LanguageServerProtocol::Diagnostic m_lspDiagnostic;
|
||||
const ClangBackEnd::DiagnosticContainer m_diagnostic;
|
||||
const QPointer<const LanguageClient::Client> m_client;
|
||||
|
||||
QMetaObject::Connection m_clientDeleted;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user