From 17f9d5abcb05da185486ccfba293f3a8c9eab437 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Tue, 10 Mar 2009 12:23:50 -0600 Subject: Fix some mem leaks --- src/gui/chat.cpp | 2 ++ src/gui/setup.cpp | 11 +++++++++-- src/gui/setup.h | 4 ++++ src/gui/setup_colors.cpp | 5 ++--- src/gui/skill.cpp | 2 +- src/gui/table.cpp | 1 + src/gui/window.cpp | 2 ++ 7 files changed, 21 insertions(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 8ecb5f63..55bc2696 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -108,6 +108,8 @@ ChatWindow::~ChatWindow() config.setValue("PartyPrefix", partyPrefix); config.setValue("ReturnToggles", mReturnToggles ? "1" : "0"); delete mRecorder; + delete mItemLinkHandler; + delete mParty; } void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord) diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index 148e8b75..62d79d4d 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -64,9 +64,9 @@ Setup::Setup(): btn->setPosition(x, height - btn->getHeight() - 5); add(btn); - // Disable this button when the windows aren't created yet + // Store this button, as it needs to be enabled/disabled if (!strcmp(*curBtn, "Reset Windows")) - btn->setEnabled(statusWindow != NULL); + mResetWindows = btn; } TabbedArea *panel = new TabbedArea; @@ -101,6 +101,8 @@ Setup::Setup(): add(panel); setLocationRelativeTo(getParent()); + + setInGame(false); } Setup::~Setup() @@ -140,3 +142,8 @@ void Setup::action(const gcn::ActionEvent &event) tradeWindow->resetToDefaultSize(); } } + +void Setup::setInGame(bool inGame) +{ + mResetWindows->setEnabled(inGame); +} \ No newline at end of file diff --git a/src/gui/setup.h b/src/gui/setup.h index e4eb0902..075c88bf 100644 --- a/src/gui/setup.h +++ b/src/gui/setup.h @@ -31,6 +31,7 @@ #include "../guichanfwd.h" class SetupTab; +class Button; /** * The setup dialog. @@ -50,6 +51,8 @@ class Setup : public Window, public gcn::ActionListener */ ~Setup(); + void setInGame(bool inGame); + /** * Event handling method. */ @@ -57,6 +60,7 @@ class Setup : public Window, public gcn::ActionListener private: std::list mTabs; + gcn::Button *mResetWindows; }; #endif diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index 49c99996..2610be03 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -57,9 +57,8 @@ Setup_Colors::Setup_Colors() : mPreview = new BrowserBox(BrowserBox::AUTO_WRAP); mPreview->setOpaque(false); - // Replace this later with a more appropriate link handler. For now, this'll - // do, as it'll do nothing when clicked on. - mPreview->setLinkHandler(new ItemLinkHandler); + // don't do anything with links + mPreview->setLinkHandler(NULL); mPreviewBox = new ScrollArea(mPreview); mPreviewBox->setHeight(20); diff --git a/src/gui/skill.cpp b/src/gui/skill.cpp index 61bb9ce9..6112f0e3 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -163,7 +163,7 @@ SkillDialog::SkillDialog(): SkillDialog::~SkillDialog() { - delete mTable; + delete_all(mSkillList); } void SkillDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/table.cpp b/src/gui/table.cpp index 1371a78e..274f9a48 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -98,6 +98,7 @@ GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, GuiTable::~GuiTable() { + uninstallActionListeners(); delete mModel; } diff --git a/src/gui/window.cpp b/src/gui/window.cpp index 8eaaf31d..be63ff21 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -142,6 +142,8 @@ Window::~Window() delete(w); } + removeWidgetListener(this); + instances--; // Clean up static resources -- cgit v1.2.3-70-g09d2