TextEditor: Fix crash on reloading the document

as part of the reload operation we set the document to nullptr inside
TextBlockUserData::documentClosing, but we do not remove the mark from
the marks cache. So when a text mark gets deleted while a document is
reloaded the mark does not get readded to the document, but it wont get
removed from the marks cache inside the document either, so we have to
manually make sure the mark is removed from the cache in this situation.

Fixes: QTCREATORBUG-29432
Change-Id: I3ae4182c4d2bbd3426c1d7a60275d21ac20ea99a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
David Schulz
2023-08-02 13:56:28 +02:00
parent 8d554aba1a
commit 66d49e6a53
4 changed files with 35 additions and 5 deletions

View File

@@ -837,7 +837,7 @@ bool TextDocument::reload(QString *errorString, const FilePath &realFilePath)
auto documentLayout =
qobject_cast<TextDocumentLayout*>(d->m_document.documentLayout());
if (documentLayout)
documentLayout->documentAboutToReload(); // removes text marks non-permanently
documentLayout->documentAboutToReload(this); // removes text marks non-permanently
bool success = openImpl(errorString, filePath(), realFilePath, /*reload =*/true)
== OpenResult::Success;