From 667188c2422f52f8c2b86387c0ffa9e370766cae Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 30 Jul 2024 12:55:28 +0200 Subject: [PATCH] BinEditor: Also create IEditors, but don't show them for memory views To simplify the different code paths, still on the way to allow duplication of editors. Change-Id: I09f8e9faee4b5b6c8179f56341997024daa8681a Reviewed-by: Christian Stenger --- src/plugins/bineditor/bineditorplugin.cpp | 29 +++++++---------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 70782895b06..81c447ae0ae 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -2262,29 +2262,18 @@ class BinEditorFactoryService final : public QObject, public FactoryService Q_INTERFACES(BinEditor::FactoryService) public: - EditorService *createEditorService(const QString &title0, bool wantsEditor) final + EditorService *createEditorService(const QString &title, bool wantsEditor) final { - if (!wantsEditor) { - auto document = new BinEditorDocument; - auto widget = new BinEditorWidget(document); - widget->setWindowTitle(title0); - - auto service = new BinEditorService; - service->m_widget = widget; - service->m_document = document; - return service; - } - - QString title = title0; - IEditor *editor = EditorManager::openEditorWithContents( - Core::Constants::K_DEFAULT_BINARY_EDITOR_ID, &title); - if (!editor) - return nullptr; + auto document = new BinEditorDocument; + auto widget = new BinEditorWidget(document); + widget->setWindowTitle(title); auto service = new BinEditorService; - service->m_editor = editor; - service->m_widget = qobject_cast(editor->widget()); - service->m_document = qobject_cast(editor->document()); + service->m_widget = widget; + service->m_document = document; + service->m_editor = new BinEditorImpl(widget, document); + if (wantsEditor) + EditorManager::activateEditor(service->m_editor); return service; } };