From df1fa271274be04f9704f6d67eb2294c03256208 Mon Sep 17 00:00:00 2001 From: Federico Fuga Date: Mon, 17 Mar 2025 10:38:10 +0100 Subject: [PATCH] Fix nasty and still unclear bug with "Close Other" not closing all tabs in certain conditions. (#725) --- src/DockAreaTabBar.cpp | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/DockAreaTabBar.cpp b/src/DockAreaTabBar.cpp index 724aedc..8de254c 100644 --- a/src/DockAreaTabBar.cpp +++ b/src/DockAreaTabBar.cpp @@ -334,27 +334,13 @@ void CDockAreaTabBar::onTabCloseRequested() void CDockAreaTabBar::onCloseOtherTabsRequested() { auto Sender = qobject_cast(sender()); - for (int i = 0; i < count(); ++i) - { - auto Tab = tab(i); - if (Tab->isClosable() && !Tab->isHidden() && Tab != Sender) - { - // If the dock widget is deleted with the closeTab() call, its tab - // it will no longer be in the layout, and thus the index needs to - // be updated to not skip any tabs - int Offset = Tab->dockWidget()->features().testFlag( - CDockWidget::DockWidgetDeleteOnClose) ? 1 : 0; - closeTab(i); - // If the dock widget blocks closing, i.e. if the flag - // CustomCloseHandling is set, and the dock widget is still open, - // then we do not need to correct the index - if (Tab->dockWidget()->isClosed()) - { - i -= Offset; - } - } - } + for (int i = count() - 1; i >= 0; --i) { + auto Tab = tab(i); + if (Tab->isClosable() && !Tab->isHidden() && Tab != Sender) { + closeTab(i); + } + } }