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:
parent
1ae2f714bb
commit
03c1fca71d
@ -327,18 +327,21 @@ void TabBar::setCurrentIndex(int index)
|
|||||||
|
|
||||||
d->tabWidgetLayout->removeAt(1);
|
d->tabWidgetLayout->removeAt(1);
|
||||||
|
|
||||||
if (index < 0) {
|
if (d->currentIndex >= 0) {
|
||||||
d->currentIndex = index;
|
d->oldPage = d->pages[d->currentIndex];
|
||||||
emit currentChanged(index);
|
} else {
|
||||||
d->tabProxy->native->setCurrentIndex(index);
|
d->oldPage = 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d->oldPage = d->pages[d->currentIndex];
|
if (index >= 0) {
|
||||||
d->newPage = d->pages[index];
|
d->newPage = d->pages[index];
|
||||||
|
} else {
|
||||||
|
d->newPage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d->newPage) {
|
||||||
d->newPage->resize(d->oldPage->size());
|
d->newPage->resize(d->oldPage->size());
|
||||||
|
}
|
||||||
|
|
||||||
setFlags(QGraphicsItem::ItemClipsChildrenToShape);
|
setFlags(QGraphicsItem::ItemClipsChildrenToShape);
|
||||||
|
|
||||||
@ -355,28 +358,36 @@ void TabBar::setCurrentIndex(int index)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d->oldPage->show();
|
if (d->newPage) {
|
||||||
d->newPage->show();
|
d->newPage->show();
|
||||||
d->newPage->setEnabled(true);
|
d->newPage->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
d->oldPage->setEnabled(false);
|
if (d->oldPage) {
|
||||||
|
d->oldPage->show();
|
||||||
|
d->oldPage->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
QRect beforeCurrentGeom(d->oldPage->geometry().toRect());
|
if (d->newPage && d->oldPage) {
|
||||||
beforeCurrentGeom.moveTopRight(beforeCurrentGeom.topLeft());
|
QRect beforeCurrentGeom(d->oldPage->geometry().toRect());
|
||||||
|
beforeCurrentGeom.moveTopRight(beforeCurrentGeom.topLeft());
|
||||||
|
|
||||||
d->newPageAnimId = Animator::self()->moveItem(
|
d->newPageAnimId = Animator::self()->moveItem(
|
||||||
d->newPage, Plasma::Animator::SlideOutMovement,
|
d->newPage, Plasma::Animator::SlideOutMovement,
|
||||||
d->oldPage->pos().toPoint());
|
d->oldPage->pos().toPoint());
|
||||||
if (index > d->currentIndex) {
|
if (index > d->currentIndex) {
|
||||||
d->newPage->setPos(d->oldPage->geometry().topRight());
|
d->newPage->setPos(d->oldPage->geometry().topRight());
|
||||||
d->oldPageAnimId = Animator::self()->moveItem(
|
d->oldPageAnimId = Animator::self()->moveItem(
|
||||||
d->oldPage, Plasma::Animator::SlideOutMovement,
|
d->oldPage, Plasma::Animator::SlideOutMovement,
|
||||||
beforeCurrentGeom.topLeft());
|
beforeCurrentGeom.topLeft());
|
||||||
|
} else {
|
||||||
|
d->newPage->setPos(beforeCurrentGeom.topLeft());
|
||||||
|
d->oldPageAnimId = Animator::self()->moveItem(
|
||||||
|
d->oldPage, Plasma::Animator::SlideOutMovement,
|
||||||
|
d->oldPage->geometry().topRight().toPoint());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
d->newPage->setPos(beforeCurrentGeom.topLeft());
|
d->tabWidgetLayout->addItem(d->newPage);
|
||||||
d->oldPageAnimId = Animator::self()->moveItem(
|
|
||||||
d->oldPage, Plasma::Animator::SlideOutMovement,
|
|
||||||
d->oldPage->geometry().topRight().toPoint());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d->currentIndex = index;
|
d->currentIndex = index;
|
||||||
|
Loading…
Reference in New Issue
Block a user