summaryrefslogtreecommitdiff
path: root/src/gui/widgets/tabbedarea.cpp
diff options
context:
space:
mode:
authorStefan Dombrowski <stefan@uni-bonn.de>2010-08-22 20:16:15 +0200
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2010-08-22 20:52:06 +0200
commit371c36f8817780a913bc2c600c2204e61267972d (patch)
tree6ad9e0c354b3db91ddafd36adced484b1de033c7 /src/gui/widgets/tabbedarea.cpp
parent0009672b80c666b8a7ddc0b7c36951eba1fa2c35 (diff)
downloadmana-371c36f8817780a913bc2c600c2204e61267972d.tar.gz
mana-371c36f8817780a913bc2c600c2204e61267972d.tar.bz2
mana-371c36f8817780a913bc2c600c2204e61267972d.tar.xz
mana-371c36f8817780a913bc2c600c2204e61267972d.zip
Fixing segmentation fault when tab gets removed
How to reproduce the bug: Leave a party, while the party tab in the chat window is not selected. Then click with the mouse on the chat window. Signed-off-by: Thorbjørn Lindeijer <thorbjorn@lindeijer.nl>
Diffstat (limited to 'src/gui/widgets/tabbedarea.cpp')
-rw-r--r--src/gui/widgets/tabbedarea.cpp20
1 files changed, 3 insertions, 17 deletions
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index a774ab22..101c9546 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -103,16 +103,12 @@ void TabbedArea::addTab(const std::string &caption, gcn::Widget *widget)
void TabbedArea::removeTab(Tab *tab)
{
- int tabIndexToBeSelected = -1;
-
if (tab == mSelectedTab)
{
- int index = getSelectedTabIndex();
-
- if (index == (int)mTabs.size() - 1 && mTabs.size() == 1)
- tabIndexToBeSelected = -1;
+ if (getNumberOfTabs() > 1)
+ setSelectedTab(std::max(0, getSelectedTabIndex() - 1));
else
- tabIndexToBeSelected = index - 1;
+ mSelectedTab = 0;
}
TabContainer::iterator iter;
@@ -137,16 +133,6 @@ void TabbedArea::removeTab(Tab *tab)
}
}
- if (tabIndexToBeSelected == -1)
- {
- mSelectedTab = NULL;
- mWidgetContainer->clear();
- }
- else
- {
- setSelectedTab(tabIndexToBeSelected);
- }
-
adjustSize();
adjustTabPositions();
}