summaryrefslogtreecommitdiff
path: root/src/gui
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
parentd2c42029b98c665725768b891aa877eb3267664f (diff)
downloadmanaplus-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.tar.gz
manaplus-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.tar.bz2
manaplus-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.tar.xz
manaplus-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.zip
Fix leaks in client, skilldialog and playerinfo classes.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/skilldialog.cpp27
-rw-r--r--src/gui/skilldialog.h1
-rw-r--r--src/gui/widgets/tabbedarea.cpp14
-rw-r--r--src/gui/widgets/tabbedarea.h4
4 files changed, 40 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);
}
diff --git a/src/gui/skilldialog.h b/src/gui/skilldialog.h
index 23cb41c46..6897c35ac 100644
--- a/src/gui/skilldialog.h
+++ b/src/gui/skilldialog.h
@@ -86,6 +86,7 @@ class SkillDialog : public Window, public gcn::ActionListener
typedef std::map<int, SkillInfo*> SkillMap;
SkillMap mSkills;
TabbedArea *mTabs;
+ std::list<Tab*> mDeleteTabs;
Label *mPointsLabel;
Button *mIncreaseButton;
SkillModel *mDefaultModel;
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index da6dfb64c..6c2ef5b25 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -428,6 +428,20 @@ void TabbedArea::updateArrowEnableState()
}
}
+Tab *TabbedArea::getTabByIndex(int index) const
+{
+ if (index < 0 || index >= static_cast<int>(mTabs.size()))
+ return 0;
+ return static_cast<Tab*>(mTabs[index].first);
+}
+
+gcn::Widget *TabbedArea::getWidgetByIndex(int index) const
+{
+ if (index < 0 || index >= static_cast<int>(mTabs.size()))
+ return 0;
+ return mTabs[index].second;
+}
+
/*
void TabbedArea::moveLeft(gcn::Tab *tab)
{
diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h
index 00c1aaf23..dccf72357 100644
--- a/src/gui/widgets/tabbedarea.h
+++ b/src/gui/widgets/tabbedarea.h
@@ -70,6 +70,10 @@ class TabbedArea : public gcn::TabbedArea, public gcn::WidgetListener
*/
Tab *getTab(const std::string &name) const;
+ Tab *getTabByIndex(int index) const;
+
+ gcn::Widget *getWidgetByIndex(int index) const;
+
/**
* Returns the widget with the tab that has specified caption
*/