properly fix previous commit don't crash setting an active page < 0

don't crash setting a new one if the old one was 0

svn path=/trunk/KDE/kdelibs/; revision=1027767
This commit is contained in:
Marco Martin 2009-09-24 18:26:48 +00:00
parent 1ae2f714bb
commit 03c1fca71d

View File

@ -327,18 +327,21 @@ void TabBar::setCurrentIndex(int index)
d->tabWidgetLayout->removeAt(1);
if (index < 0) {
d->currentIndex = index;
emit currentChanged(index);
d->tabProxy->native->setCurrentIndex(index);
return;
if (d->currentIndex >= 0) {
d->oldPage = d->pages[d->currentIndex];
} else {
d->oldPage = 0;
}
d->oldPage = d->pages[d->currentIndex];
if (index >= 0) {
d->newPage = d->pages[index];
} else {
d->newPage = 0;
}
if (d->newPage) {
d->newPage->resize(d->oldPage->size());
}
setFlags(QGraphicsItem::ItemClipsChildrenToShape);
@ -355,12 +358,17 @@ void TabBar::setCurrentIndex(int index)
}
}
d->oldPage->show();
if (d->newPage) {
d->newPage->show();
d->newPage->setEnabled(true);
}
if (d->oldPage) {
d->oldPage->show();
d->oldPage->setEnabled(false);
}
if (d->newPage && d->oldPage) {
QRect beforeCurrentGeom(d->oldPage->geometry().toRect());
beforeCurrentGeom.moveTopRight(beforeCurrentGeom.topLeft());
@ -378,6 +386,9 @@ void TabBar::setCurrentIndex(int index)
d->oldPage, Plasma::Animator::SlideOutMovement,
d->oldPage->geometry().topRight().toPoint());
}
} else {
d->tabWidgetLayout->addItem(d->newPage);
}
d->currentIndex = index;
emit currentChanged(index);