forked from qt-creator/qt-creator
Debugger: Fix memory view as an editor
`EditorManager::activateEditor` assumes that the editor is already known to the editor manager. Add a dedicated `EditorManager::addEditor` method for making an IEditor instance known to the editor manager and activating it (if wanted). Change-Id: I0c1632b6a3b32f54a01da0ad632fa17e2b1a850f Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -2319,8 +2319,9 @@ public:
|
||||
auto document = std::make_shared<BinEditorDocument>();
|
||||
auto service = new BinEditorImpl(document);
|
||||
service->widget()->setWindowTitle(title);
|
||||
service->document()->setPreferredDisplayName(title);
|
||||
if (wantsEditor)
|
||||
EditorManager::activateEditor(service);
|
||||
EditorManager::addEditor(service);
|
||||
return service;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1420,6 +1420,8 @@ IEditor *EditorManagerPrivate::placeEditor(EditorView *view, IEditor *editor)
|
||||
if (IEditor *e = view->editorForDocument(editor->document()))
|
||||
return e;
|
||||
|
||||
QTC_CHECK(DocumentModel::editorsForDocument(editor->document()).contains(editor));
|
||||
|
||||
const QByteArray state = editor->saveState();
|
||||
if (EditorView *sourceView = viewForEditor(editor)) {
|
||||
// try duplication or pull editor over to new view
|
||||
@@ -3151,6 +3153,17 @@ IEditor *EditorManager::activateEditorForDocument(IDocument *document, OpenEdito
|
||||
flags);
|
||||
}
|
||||
|
||||
/*!
|
||||
Makes an IEditor instance \a editor known to the EditorManager that it did
|
||||
not know before, and activates it using \a flags.
|
||||
*/
|
||||
void EditorManager::addEditor(IEditor *editor, OpenEditorFlags flags)
|
||||
{
|
||||
QTC_ASSERT(!DocumentModel::editorsForDocument(editor->document()).contains(editor), return);
|
||||
d->addEditor(editor);
|
||||
activateEditor(editor, flags);
|
||||
}
|
||||
|
||||
/*!
|
||||
Opens the document specified by \a filePath using the editor type \a
|
||||
editorId and the specified \a flags.
|
||||
|
||||
@@ -99,6 +99,8 @@ public:
|
||||
static void activateEditorForEntry(DocumentModel::Entry *entry, OpenEditorFlags flags = NoFlags);
|
||||
static IEditor *activateEditorForDocument(IDocument *document, OpenEditorFlags flags = NoFlags);
|
||||
|
||||
static void addEditor(IEditor *editor, OpenEditorFlags flags = NoFlags);
|
||||
|
||||
static bool closeDocuments(const QList<IDocument *> &documents, bool askAboutModifiedEditors = true);
|
||||
static bool closeDocuments(const QList<DocumentModel::Entry *> &entries);
|
||||
static void closeOtherDocuments(IDocument *document);
|
||||
|
||||
Reference in New Issue
Block a user