Fix issues with Design mode and multiple editor windows

Amends 6f56310e31

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 <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2024-09-02 13:51:59 +02:00
parent aea4c09497
commit b7167838a3

View File

@@ -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).