From 2a2d469d7d5e9f0258cdd35afc5a82d11cc3c358 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 14 May 2025 18:11:09 -0400 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 (cherry picked from commit 97d5be9d81c3bb32014721c857f35ad10ea71054) 3f287b20 Make sure that ChatDocumentHandler can handle the document being changed to a nullptr. Co-authored-by: James Graham --- src/chatdocumenthandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/chatdocumenthandler.cpp b/src/chatdocumenthandler.cpp index 5ff6ab6bf..f266ab64a 100644 --- a/src/chatdocumenthandler.cpp +++ b/src/chatdocumenthandler.cpp @@ -117,6 +117,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]() {