backport a fix to a crash when removing the currently active tab

svn path=/branches/KDE/4.2/kdelibs/; revision=916690
This commit is contained in:
Marco Martin 2009-01-25 19:22:36 +00:00
parent 107173a80e
commit 9683275509

View File

@ -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());
}