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); + } + } }