summaryrefslogtreecommitdiff
path: root/src/gui/skilldialog.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-05-24 02:54:01 +0300
committerAndrei Karas <akaras@inbox.ru>2011-05-24 02:54:01 +0300
commita0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd (patch)
treeb666fed3ff9bdea61159190035d697ea562c4faa /src/gui/skilldialog.cpp
parentd2c42029b98c665725768b891aa877eb3267664f (diff)
downloadmv-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.tar.gz
mv-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.tar.bz2
mv-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.tar.xz
mv-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.zip
Fix leaks in client, skilldialog and playerinfo classes.
Diffstat (limited to 'src/gui/skilldialog.cpp')
-rw-r--r--src/gui/skilldialog.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp
index ee1803604..7163d5285 100644
--- a/src/gui/skilldialog.cpp
+++ b/src/gui/skilldialog.cpp
@@ -144,8 +144,16 @@ class SkillListBox : public ListBox
{
public:
SkillListBox(SkillModel *model):
- ListBox(model)
- {}
+ ListBox(model),
+ mModel(model)
+ {
+ }
+
+ ~SkillListBox()
+ {
+ delete mModel;
+ mModel = 0;
+ }
SkillInfo *getSelectedInfo()
{
@@ -196,6 +204,9 @@ public:
unsigned int getRowHeight() const
{ return 34; }
+
+private:
+ SkillModel *mModel;
};
class SkillTab : public Tab
@@ -308,12 +319,14 @@ void SkillDialog::loadSkills(const std::string &file)
{
mTabs->setSelectedTab(static_cast<unsigned int>(0));
- while (mTabs->getSelectedTabIndex() != -1)
+ while (mTabs->getNumberOfTabs() > 0)
{
- gcn::Tab *tab = mTabs->getSelectedTab();
- if (tab)
- mTabs->removeTabWithIndex(mTabs->getSelectedTabIndex());
+ const int idx = mTabs->getNumberOfTabs() - 1;
+ Tab *tab = mTabs->getTabByIndex(idx);
+ Widget *widget = mTabs->getWidgetByIndex(idx);
+ mTabs->removeTab(tab);
delete tab;
+ delete widget;
}
}
@@ -363,6 +376,7 @@ void SkillDialog::loadSkills(const std::string &file)
scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
tab = new SkillTab("Skills", listbox);
+ mDeleteTabs.push_back(tab);
mTabs->addTab(tab, scroll);
@@ -417,6 +431,7 @@ void SkillDialog::loadSkills(const std::string &file)
scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS);
tab = new SkillTab(setName, listbox);
+ mDeleteTabs.push_back(tab);
mTabs->addTab(tab, scroll);
}