From 7d46060af011737caa2f673d601898abcd3a4e48 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 17 Jun 2019 12:04:47 +0200 Subject: [PATCH] Fix disabled close button in designer editor tool bar It was never actually updating when switching the editor. An update was just accidentally triggered when the designer plugin updated the editor XML when switching modes, which triggered an intermediate document change signal. Get rid of the separate code paths for setting the current editor for "standalone" editor tool bars and the tool bars in editor views, which implicitly corrects the update behavior in the former case. Fixes: QTCREATORBUG-22553 Change-Id: Ieb9f4b53600e1e1b66695ec86164628025df73f8 Reviewed-by: David Schulz --- src/plugins/coreplugin/editortoolbar.cpp | 15 ++++----------- src/plugins/coreplugin/editortoolbar.h | 1 - 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp index 28ed8a9acc3..c23aaa49d29 100644 --- a/src/plugins/coreplugin/editortoolbar.cpp +++ b/src/plugins/coreplugin/editortoolbar.cpp @@ -298,8 +298,10 @@ void EditorToolBar::setToolbarCreationFlags(ToolbarCreationFlags flags) { d->m_isStandalone = flags & FlagsStandalone; if (d->m_isStandalone) { - connect(EditorManager::instance(), &EditorManager::currentEditorChanged, - this, &EditorToolBar::updateEditorListSelection); + connect(EditorManager::instance(), + &EditorManager::currentEditorChanged, + this, + &EditorToolBar::setCurrentEditor); disconnect(d->m_editorList, static_cast(&QComboBox::activated), this, &EditorToolBar::listSelectionActivated); @@ -330,15 +332,6 @@ void EditorToolBar::setCurrentEditor(IEditor *editor) updateDocumentStatus(document); } -void EditorToolBar::updateEditorListSelection(IEditor *newSelection) -{ - if (newSelection) { - const Utils::optional index = DocumentModel::rowOfDocument(newSelection->document()); - if (QTC_GUARD(index)) - d->m_editorList->setCurrentIndex(index.value()); - } -} - void EditorToolBar::changeActiveEditor(int row) { EditorManager::activateEditorForEntry(DocumentModel::entryAtRow(row)); diff --git a/src/plugins/coreplugin/editortoolbar.h b/src/plugins/coreplugin/editortoolbar.h index b8d7fad468e..0d82e58303a 100644 --- a/src/plugins/coreplugin/editortoolbar.h +++ b/src/plugins/coreplugin/editortoolbar.h @@ -105,7 +105,6 @@ private: void updateActionShortcuts(); void updateDocumentStatus(IDocument *document); - void updateEditorListSelection(IEditor *newSelection); void fillListContextMenu(QMenu *menu); void updateToolBar(QWidget *toolBar);