From a0b5f5fee9809670c2c9cf9b1f63ab2be11fd9fd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 24 May 2011 02:54:01 +0300 Subject: Fix leaks in client, skilldialog and playerinfo classes. --- src/gui/skilldialog.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/gui/skilldialog.cpp') 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(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); } -- cgit v1.2.3-70-g09d2