From d7ed05ae14e3ced9fc57707085da56de6a35cd9e Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 13 Jun 2024 12:57:55 +0200 Subject: [PATCH] ClangTools: Do not assume there is a corresponding open document ... when creating a TextMark. Amends 2ad12b5b2c24018c89e91ef0b2355b3ac65edbaf. Change-Id: Ic748012dadda0fc94814176589a3bdff20cb4cd6 Reviewed-by: David Schulz --- src/plugins/clangtools/diagnosticmark.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plugins/clangtools/diagnosticmark.cpp b/src/plugins/clangtools/diagnosticmark.cpp index 90b4e19812d..5ea0895b947 100644 --- a/src/plugins/clangtools/diagnosticmark.cpp +++ b/src/plugins/clangtools/diagnosticmark.cpp @@ -20,10 +20,13 @@ using namespace Utils; namespace ClangTools { namespace Internal { +static TextMarkCategory clangToolsCategory() +{ + return {Tr::tr("Clang Tools"), Id(Constants::DIAGNOSTIC_MARK_ID)}; +} + DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic, TextDocument *document) - : TextMark(document, - diagnostic.location.line, - {Tr::tr("Clang Tools"), Id(Constants::DIAGNOSTIC_MARK_ID)}) + : TextMark(document, diagnostic.location.line, clangToolsCategory()) , m_diagnostic(diagnostic) { setSettingsPage(Constants::SETTINGS_PAGE_ID); @@ -60,7 +63,8 @@ DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic, TextDocument *docum } DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic) - : DiagnosticMark(diagnostic, TextDocument::textDocumentForFilePath(diagnostic.location.filePath)) + : TextMark(diagnostic.location.filePath, diagnostic.location.line, clangToolsCategory()) + , m_diagnostic(diagnostic) {} void DiagnosticMark::disable()