diff options
author | David Athay <ko2fan@gmail.com> | 2008-04-18 15:23:49 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2008-04-18 15:23:49 +0000 |
commit | 4371c8c1ffcf24e8d5a7cf2ec126be239cab3d76 (patch) | |
tree | 831d9d2e909dabab0ee2c6ed640e290ee28ad294 /src/gui/widgets/tabbedarea.cpp | |
parent | 0b567928c0a24c7346451b59285ce8144ae0bf2e (diff) | |
download | mana-client-4371c8c1ffcf24e8d5a7cf2ec126be239cab3d76.tar.gz mana-client-4371c8c1ffcf24e8d5a7cf2ec126be239cab3d76.tar.bz2 mana-client-4371c8c1ffcf24e8d5a7cf2ec126be239cab3d76.tar.xz mana-client-4371c8c1ffcf24e8d5a7cf2ec126be239cab3d76.zip |
Fixed numerous crashes with chat and guild windows using new tabbed area.
Diffstat (limited to 'src/gui/widgets/tabbedarea.cpp')
-rw-r--r-- | src/gui/widgets/tabbedarea.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 9087babc..5402bb10 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -87,3 +87,58 @@ gcn::Widget* TabbedArea::getWidget(const std::string &name) return NULL; } + +void TabbedArea::removeTab(gcn::Tab *tab) +{ + int tabIndexToBeSelected = 0; + + if (tab == mSelectedTab) + { + int index = getSelectedTabIndex(); + + if (index == (int)mTabs.size() - 1 + && mTabs.size() == 1) + { + tabIndexToBeSelected = -1; + } + else + { + tabIndexToBeSelected = index - 1; + } + } + + std::vector<std::pair<gcn::Tab*, gcn::Widget*> >::iterator iter; + for (iter = mTabs.begin(); iter != mTabs.end(); iter++) + { + if (iter->first == tab) + { + mTabContainer->remove(tab); + mTabs.erase(iter); + break; + } + } + + std::vector<gcn::Tab*>::iterator iter2; + for (iter2 = mTabsToDelete.begin(); iter2 != mTabsToDelete.end(); iter2++) + { + if (*iter2 == tab) + { + mTabsToDelete.erase(iter2); + delete tab; + break; + } + } + + if (tabIndexToBeSelected == -1) + { + mSelectedTab = NULL; + mWidgetContainer->clear(); + } + else + { + setSelectedTab(tabIndexToBeSelected); + } + + adjustSize(); + adjustTabPositions(); +} |