From 91a51ec64c35713914b22f2d9a283dc5b4091c12 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 30 Mar 2011 23:57:40 +0300 Subject: Fix memory leaks and some other errors. --- src/gui/login.cpp | 5 ++++- src/gui/login.h | 2 ++ src/gui/widgets/itemcontainer.cpp | 1 + src/gui/widgets/tabbedarea.cpp | 11 ++++------- src/gui/widgets/window.cpp | 2 ++ 5 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src/gui') diff --git a/src/gui/login.cpp b/src/gui/login.cpp index 853276dca..d910d37bc 100644 --- a/src/gui/login.cpp +++ b/src/gui/login.cpp @@ -106,7 +106,8 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName, mKeepCheck = new CheckBox(_("Remember username"), mLoginData->remember); mUpdateTypeLabel = new Label(_("Update:")); - mUpdateTypeDropDown = new DropDown(new UpdateTypeModel()); + mUpdateTypeModel = new UpdateTypeModel(); + mUpdateTypeDropDown = new DropDown(mUpdateTypeModel); mUpdateTypeDropDown->setActionEventId("updatetype"); mUpdateTypeDropDown->setSelected((loginData->updateType | LoginData::Upd_Custom) ^ LoginData::Upd_Custom); @@ -161,6 +162,8 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName, LoginDialog::~LoginDialog() { + delete mUpdateTypeModel; + mUpdateTypeModel = 0; } void LoginDialog::action(const gcn::ActionEvent &event) diff --git a/src/gui/login.h b/src/gui/login.h index 49d1aa199..9a65e9718 100644 --- a/src/gui/login.h +++ b/src/gui/login.h @@ -33,6 +33,7 @@ #include class LoginData; +class UpdateTypeModel; /** * The login dialog. @@ -86,6 +87,7 @@ class LoginDialog : public Window, public gcn::ActionListener, LoginData *mLoginData; std::string *mUpdateHost; + UpdateTypeModel *mUpdateTypeModel; }; #endif diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index c9f1269aa..b76385f03 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -130,6 +130,7 @@ ItemContainer::~ItemContainer() } delete mItemPopup; mItemPopup = 0; + delete []mShowMatrix; } void ItemContainer::logic() diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index f4b4a78f8..6b90cb381 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -46,13 +46,10 @@ TabbedArea::TabbedArea() : gcn::TabbedArea(), TabbedArea::~TabbedArea() { - if (!mEnableScrollButtons) - { - delete mArrowButton[0]; - mArrowButton[0] = 0; - delete mArrowButton[1]; - mArrowButton[1] = 0; - } + delete mArrowButton[0]; + mArrowButton[0] = 0; + delete mArrowButton[1]; + mArrowButton[1] = 0; } void TabbedArea::enableScrollButtons(bool enable) diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 22daa5dc9..3531ac245 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -106,6 +106,8 @@ Window::~Window() while (!mWidgets.empty()) delete mWidgets.front(); + mWidgets.clear(); + // need mWidgets.clean ? removeWidgetListener(this); -- cgit v1.2.3-70-g09d2