don't crash when removing the currently active tab
will backport to 4.2 svn path=/trunk/KDE/kdelibs/; revision=916689
This commit is contained in:
parent
21144164ff
commit
d0fb10f0cc
@ -360,18 +360,23 @@ void TabBar::removeTab(int index)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentIndex = d->tabProxy->native->currentIndex();
|
int oldCurrentIndex = d->tabProxy->native->currentIndex();
|
||||||
|
|
||||||
d->tabProxy->native->removeTab(index);
|
d->tabProxy->native->removeTab(index);
|
||||||
QGraphicsWidget *page = d->pages.takeAt(index);
|
QGraphicsWidget *page = d->pages.takeAt(index);
|
||||||
|
|
||||||
if (index == currentIndex) {
|
int currentIndex = d->tabProxy->native->currentIndex();
|
||||||
setCurrentIndex(currentIndex);
|
|
||||||
|
if (oldCurrentIndex == index) {
|
||||||
|
d->tabWidgetLayout->removeAt(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
scene()->removeItem(page);
|
scene()->removeItem(page);
|
||||||
page->deleteLater();
|
page->deleteLater();
|
||||||
|
|
||||||
|
if (oldCurrentIndex != currentIndex) {
|
||||||
|
setCurrentIndex(currentIndex);
|
||||||
|
}
|
||||||
|
|
||||||
d->updateTabWidgetMode();
|
d->updateTabWidgetMode();
|
||||||
d->tabProxy->setPreferredSize(d->tabProxy->native->sizeHint());
|
d->tabProxy->setPreferredSize(d->tabProxy->native->sizeHint());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user