From b7167838a3808d89a5f32831bac2ec3aba2bb435 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 2 Sep 2024 13:51:59 +0200 Subject: [PATCH] Fix issues with Design mode and multiple editor windows Amends 6f56310e31b8d6440e06f376fff66261b1ed0384 That change makes sure that we most of the time have a "current editor view" that is visible. Changing the current editor view implicitly means changing the "current editor". When switching to a .ui file in edit mode in the main window, that switches to Design mode. That hides the main editor view, so the code above switches the current editor view to an external editor window, if that exists and was ever active. Which in turn switches the current editor which disables Design mode (if that isn't a different .ui file). That made it impossible to open a .ui file in Design mode via switching to it in Edit mode. This adds a hack/workaround that disables the logic from the previous change, if the current view is hidden and Design mode is active. It would be better if Design mode was not so tightly coupled to the current editor. Fixes: QTCREATORBUG-31378 Change-Id: I9120fcda9752125eb8c7b653ca406960e7101397 Reviewed-by: David Schulz --- .../coreplugin/editormanager/editormanager.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 91871b20e16..1112620431f 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -1870,6 +1870,18 @@ void EditorManagerPrivate::addEditorArea(EditorArea *area) }; if (isReallyVisibile(area)) return; + + // Hack for the case that the hidden area has the current editor, + // and that is currently shown in Design mode. We may not switch the + // current editor (so not switch the current view) in that case. + // QTCREATORBUG-31378 + // It would be good if the Design mode didn't rely on the current + // editor, instead. + if (area->currentView() == currentEditorView() + && ModeManager::currentModeId() == Constants::MODE_DESIGN) { + return; + } + // In case the hidden editor area has the current view, look for a view // that is not hidden, iterating through the history of current views. // This could be the first==current view (which results in a no-op).