forked from qt-creator/qt-creator
EditorManager: Guard against potential crash
At this point `entry` should not be nullptr, since the editors passed to
closeEditor should be ones that are managed by EditorManager/
DocumentModel. But there could be misusage of the EditorManager API, or
some other corruption of the managed data in DocumentModel, so be
defensive.
Amends 119a0920c1
Task-number: QTCREATORBUG-32484
Change-Id: I3f173d1fe7c3533d4f044fd23171c69ab65bb9d8
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -1618,7 +1618,8 @@ bool EditorManagerPrivate::closeEditors(const QList<IEditor*> &editors, CloseFla
|
||||
emit m_instance->editorAboutToClose(editor);
|
||||
const DocumentModel::Entry *entry = DocumentModel::entryForDocument(editor->document());
|
||||
// If the file is pinned, closing it should remove the editor but keep it in Open Documents.
|
||||
const bool removeSuspendedEntry = !entry->pinned && flag != CloseFlag::Suspend;
|
||||
const bool isPinned = QTC_GUARD(entry) && entry->pinned;
|
||||
const bool removeSuspendedEntry = !isPinned && flag != CloseFlag::Suspend;
|
||||
removeEditor(editor, removeSuspendedEntry);
|
||||
if (EditorView *view = viewForEditor(editor)) {
|
||||
editorsPerView.insert(view, editor);
|
||||
|
Reference in New Issue
Block a user