From 96832755098514c28232a98c40a6410e9fe3be0e Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sun, 25 Jan 2009 19:22:36 +0000 Subject: [PATCH] backport a fix to a crash when removing the currently active tab svn path=/branches/KDE/4.2/kdelibs/; revision=916690 --- widgets/tabbar.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/widgets/tabbar.cpp b/widgets/tabbar.cpp index 478d59a49..d655e7d9e 100644 --- a/widgets/tabbar.cpp +++ b/widgets/tabbar.cpp @@ -360,18 +360,23 @@ void TabBar::removeTab(int index) return; } - int currentIndex = d->tabProxy->native->currentIndex(); - + int oldCurrentIndex = d->tabProxy->native->currentIndex(); d->tabProxy->native->removeTab(index); QGraphicsWidget *page = d->pages.takeAt(index); - if (index == currentIndex) { - setCurrentIndex(currentIndex); + int currentIndex = d->tabProxy->native->currentIndex(); + + if (oldCurrentIndex == index) { + d->tabWidgetLayout->removeAt(1); } scene()->removeItem(page); page->deleteLater(); + if (oldCurrentIndex != currentIndex) { + setCurrentIndex(currentIndex); + } + d->updateTabWidgetMode(); d->tabProxy->setPreferredSize(d->tabProxy->native->sizeHint()); }