From fc6e4c75e29c26b46af5d0c17bbd124211563e4c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 16 Apr 2011 22:00:30 +0300 Subject: Fix some possible memory leaks. --- src/gui/textcommandeditor.cpp | 15 ++++++++++++--- src/gui/textcommandeditor.h | 18 ++++++++++++------ src/gui/widgets/button.cpp | 2 ++ 3 files changed, 26 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/gui/textcommandeditor.cpp b/src/gui/textcommandeditor.cpp index 019827048..45bff6b03 100644 --- a/src/gui/textcommandeditor.cpp +++ b/src/gui/textcommandeditor.cpp @@ -198,13 +198,15 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): mManaField->setRange(0, 500); mManaField->setWidth(20); + mTargetTypeModel = new TargetTypeModel; mTypeLabel = new Label(_("Target Type:")); - mTypeDropDown = new DropDown(new TargetTypeModel); + mTypeDropDown = new DropDown(mTargetTypeModel); mTypeDropDown->setActionEventId("type"); mTypeDropDown->addActionListener(this); + mIconsModal = new IconsModal; mIconLabel = new Label(_("Icon:")); - mIconDropDown = new DropDown(new IconsModal); + mIconDropDown = new DropDown(mIconsModal); mIconDropDown->setActionEventId("icon"); mIconDropDown->addActionListener(this); mIconDropDown->setSelectedString(mCommand->getIcon()); @@ -214,8 +216,9 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): mMagicLvlField->setRange(0, 5); mMagicLvlField->setWidth(20); + mMagicSchoolModel = new MagicSchoolModel; mSchoolLabel = new Label(_("Magic School:")); - mSchoolDropDown = new DropDown(new MagicSchoolModel); + mSchoolDropDown = new DropDown(mMagicSchoolModel); mSchoolDropDown->setActionEventId("school"); mSchoolDropDown->addActionListener(this); mSchoolDropDown->setSelected(0); @@ -286,6 +289,12 @@ TextCommandEditor::TextCommandEditor(TextCommand *command): TextCommandEditor::~TextCommandEditor() { + delete mIconsModal; + mIconsModal = 0; + delete mTargetTypeModel; + mTargetTypeModel = 0; + delete mMagicSchoolModel; + mMagicSchoolModel = 0; } void TextCommandEditor::action(const gcn::ActionEvent &event) diff --git a/src/gui/textcommandeditor.h b/src/gui/textcommandeditor.h index 9f8c0ad51..cb88b8160 100644 --- a/src/gui/textcommandeditor.h +++ b/src/gui/textcommandeditor.h @@ -29,15 +29,18 @@ #include -class RadioButton; -class Label; -class TextBox; -class TextField; +class Button; class DropDown; +class IconsModal; +class IntTextField; +class Label; class ListModel; -class Button; +class MagicSchoolModel; +class RadioButton; +class TargetTypeModel; +class TextBox; class TextCommand; -class IntTextField; +class TextField; class TextCommandEditor : public Window, public gcn::ActionListener { @@ -92,6 +95,9 @@ class TextCommandEditor : public Window, public gcn::ActionListener DropDown *mSchoolDropDown; Label *mSchoolLvlLabel; IntTextField *mSchoolLvlField; + IconsModal *mIconsModal; + TargetTypeModel *mTargetTypeModel; + MagicSchoolModel *mMagicSchoolModel; //Button *mAdvancedButton; Button *mCancelButton; diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index a8e8b656d..91d297846 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -135,6 +135,8 @@ Button::~Button() { mInstances--; + delete mVertexes; + mVertexes = 0; if (mInstances == 0) { for (int mode = 0; mode < BUTTON_COUNT; mode++) -- cgit v1.2.3-70-g09d2