diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-05-24 02:54:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-05-24 02:54:01 +0300 |
commit | a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd (patch) | |
tree | b666fed3ff9bdea61159190035d697ea562c4faa | |
parent | d2c42029b98c665725768b891aa877eb3267664f (diff) | |
download | manaverse-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.tar.gz manaverse-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.tar.bz2 manaverse-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.tar.xz manaverse-a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd.zip |
Fix leaks in client, skilldialog and playerinfo classes.
-rw-r--r-- | src/client.cpp | 5 | ||||
-rw-r--r-- | src/gui/skilldialog.cpp | 27 | ||||
-rw-r--r-- | src/gui/skilldialog.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/tabbedarea.cpp | 14 | ||||
-rw-r--r-- | src/gui/widgets/tabbedarea.h | 4 | ||||
-rw-r--r-- | src/playerinfo.cpp | 6 | ||||
-rw-r--r-- | src/playerinfo.h | 2 |
7 files changed, 53 insertions, 6 deletions
diff --git a/src/client.cpp b/src/client.cpp index 96d21c96c..95dc472f4 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -566,6 +566,11 @@ Client::~Client() NPCDB::unload(); StatusEffect::unload(); + delete mumbleManager; + mumbleManager = 0; + + PlayerInfo::deinit(); + // Before config.write() since it writes the shortcuts to the config for (int f = 0; f < SHORTCUT_TABS; f ++) { 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 */ diff --git a/src/playerinfo.cpp b/src/playerinfo.cpp index fb78e0ae8..72b091244 100644 --- a/src/playerinfo.cpp +++ b/src/playerinfo.cpp @@ -330,4 +330,10 @@ void init() mListener = new PlayerInfoListener(); } +void deinit() +{ + delete mListener; + mListener = 0; +} + } // namespace PlayerInfo diff --git a/src/playerinfo.h b/src/playerinfo.h index 7618b3ebd..401dd26e0 100644 --- a/src/playerinfo.h +++ b/src/playerinfo.h @@ -223,6 +223,8 @@ namespace PlayerInfo */ void init(); + void deinit(); + void triggerAttr(int id); void triggerAttr(int id, int old); |