summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStanislav Yelenskiy <qt@devstas.com>2020-09-25 00:17:28 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-10-21 07:19:36 +0000
commitb39b018f4a54252ee7a9ffada6d0f05f5896baaf (patch)
tree7092aa63b37b36e2611e58421a793f3071634bc9 /src
parent9f9275f82f6117c18eadee289c7df525aab187ee (diff)
QTabBar: update index of last visible tab in insertTab
Index of the last visible tab was not updated, if a new tab was inserted after the current tab and before the last tab. When the new tab is inserted before the last visible tab, the index of the last tab increments by one. When the new tab is inserted after the last visible tab, then the newly inserted tab becomes the last visible. Fixes: QTBUG-86898 Change-Id: I2f4b7f705261ec35a5aa7b883ecdddba25f007b7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qtabbar.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index ab4478a98b..2c65240434 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -990,14 +990,16 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)
d->tabList.at(index)->shortcutId = grabShortcut(QKeySequence::mnemonic(text));
#endif
d->firstVisible = qMax(qMin(index, d->firstVisible), 0);
- d->lastVisible = qMax(index, d->lastVisible);
d->refresh();
if (d->tabList.count() == 1)
setCurrentIndex(index);
- else if (index <= d->currentIndex) {
+ else if (index <= d->currentIndex)
++d->currentIndex;
+
+ if (index <= d->lastVisible)
++d->lastVisible;
- }
+ else
+ d->lastVisible = index;
if (d->closeButtonOnTabs) {
QStyleOptionTab opt;