From 97d5be9d81c3bb32014721c857f35ad10ea71054 Mon Sep 17 00:00:00 2001 From: James Graham Date: Mon, 5 May 2025 15:45:50 +0100 Subject: [PATCH] Make sure that ChatDocumentHandler can handle the document being changed to a nullptr Make sure that ChatDocumentHandler can handle the document being changed to a nullptr. BUG: 501950 --- src/libneochat/chatdocumenthandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libneochat/chatdocumenthandler.cpp b/src/libneochat/chatdocumenthandler.cpp index ff0946d07..4cd354f11 100644 --- a/src/libneochat/chatdocumenthandler.cpp +++ b/src/libneochat/chatdocumenthandler.cpp @@ -118,6 +118,10 @@ ChatDocumentHandler::ChatDocumentHandler(QObject *parent) }); }); connect(this, &ChatDocumentHandler::documentChanged, this, [this]() { + if (!m_document) { + m_highlighter->setDocument(nullptr); + return; + } m_highlighter->setDocument(m_document->textDocument()); }); connect(this, &ChatDocumentHandler::cursorPositionChanged, this, [this]() {