forked from qt-creator/qt-creator
ClangCodeModel: Keep a QPointer to the ClangdClient in ClangdTextMark
Apparently, the pointer might already be invalid when addToolTipContent() is called. Change-Id: I649bdca0945247b2b8ce4f709721c4d0bf96a11b Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -48,7 +48,6 @@
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QLayout>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
|
||||
using namespace CppTools;
|
||||
@@ -394,7 +393,7 @@ ClangdTextMark::ClangdTextMark(const FilePath &filePath,
|
||||
|
||||
bool ClangdTextMark::addToolTipContent(QLayout *target) const
|
||||
{
|
||||
const auto canApplyFixIt = [c = QPointer(m_client), diag = m_lspDiagnostic, fp = fileName()] {
|
||||
const auto canApplyFixIt = [c = m_client, diag = m_lspDiagnostic, fp = fileName()] {
|
||||
return c && c->reachable() && c->hasDiagnostic(DocumentUri::fromFilePath(fp), diag);
|
||||
};
|
||||
target->addWidget(ClangDiagnosticWidget::createWidget({m_diagnostic},
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <texteditor/textmark.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace LanguageClient { class Client; }
|
||||
@@ -77,7 +79,7 @@ private:
|
||||
|
||||
const LanguageServerProtocol::Diagnostic m_lspDiagnostic;
|
||||
const ClangBackEnd::DiagnosticContainer m_diagnostic;
|
||||
const LanguageClient::Client * const m_client;
|
||||
const QPointer<const LanguageClient::Client> m_client;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user