forked from qt-creator/qt-creator
TextEditor: fix crash on reload
Since TextDocument::openImpl potentially processes events it could delete TextMarks. So tracking them in TextDocument::reload can be considered unsafe. Track them in TextDocumentLayout instead and remove the tracked mark if it gets deleted while reloading the document. Task-number: QTCREATORBUG-29004 Change-Id: I9d0478e9c763b49f145c1bbaeed1a0b602757014 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -836,15 +836,14 @@ bool TextDocument::reload(QString *errorString, const FilePath &realFilePath)
|
||||
emit aboutToReload();
|
||||
auto documentLayout =
|
||||
qobject_cast<TextDocumentLayout*>(d->m_document.documentLayout());
|
||||
TextMarks marks;
|
||||
if (documentLayout)
|
||||
marks = documentLayout->documentClosing(); // removes text marks non-permanently
|
||||
documentLayout->documentAboutToReload(); // removes text marks non-permanently
|
||||
|
||||
bool success = openImpl(errorString, filePath(), realFilePath, /*reload =*/true)
|
||||
== OpenResult::Success;
|
||||
|
||||
if (documentLayout)
|
||||
documentLayout->documentReloaded(marks, this); // re-adds text marks
|
||||
documentLayout->documentReloaded(this); // re-adds text marks
|
||||
emit reloadFinished(success);
|
||||
return success;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user