diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-02-08 22:31:38 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-02-08 22:31:38 +0100 |
commit | bc5c031e43eff506c925682349dd2a52b89d6565 (patch) | |
tree | 6c429dfa2386fcde5e1e9b8f8994dc8bd77b0b2f /src | |
parent | ed39c71b2b6b47931f352ca07b49f631d6bf713a (diff) | |
download | mana-bc5c031e43eff506c925682349dd2a52b89d6565.tar.gz mana-bc5c031e43eff506c925682349dd2a52b89d6565.tar.bz2 mana-bc5c031e43eff506c925682349dd2a52b89d6565.tar.xz mana-bc5c031e43eff506c925682349dd2a52b89d6565.zip |
Delete models explicitly rather than relying on booleans
It is more clear in the end. Also fixed deleting of the mode list model.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/setup_video.cpp | 9 | ||||
-rw-r--r-- | src/gui/setup_video.h | 9 | ||||
-rw-r--r-- | src/gui/widgets/dropdown.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/dropdown.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/listbox.cpp | 9 | ||||
-rw-r--r-- | src/gui/widgets/listbox.h | 4 |
6 files changed, 21 insertions, 16 deletions
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index 9c6c8dad..20ad23e0 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -236,7 +236,8 @@ Setup_Video::Setup_Video(): particleDetailLabel = new Label(_("Particle detail")); fontSizeLabel = new Label(_("Font size")); - mFontSizeDropDown = new DropDown(new FontSizeChoiceListModel, true); + mFontSizeListModel = new FontSizeChoiceListModel; + mFontSizeDropDown = new DropDown(mFontSizeListModel); mModeList->setEnabled(true); @@ -346,6 +347,12 @@ Setup_Video::Setup_Video(): setDimension(gcn::Rectangle(0, 0, 365, 300)); } +Setup_Video::~Setup_Video() +{ + delete mModeListModel; + delete mFontSizeListModel; +} + void Setup_Video::apply() { // Full screen changes diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h index f65b78ff..e3bd62b1 100644 --- a/src/gui/setup_video.h +++ b/src/gui/setup_video.h @@ -30,11 +30,15 @@ #include <guichan/actionlistener.hpp> #include <guichan/keylistener.hpp> +class ModeListModel; +class FontSizeChoiceListModel; + class Setup_Video : public SetupTab, public gcn::ActionListener, public gcn::KeyListener { public: Setup_Video(); + ~Setup_Video(); void apply(); void cancel(); @@ -62,7 +66,8 @@ class Setup_Video : public SetupTab, public gcn::ActionListener, int mFps; Being::Speech mSpeechMode; - class ModeListModel *mModeListModel; + ModeListModel *mModeListModel; + FontSizeChoiceListModel *mFontSizeListModel; gcn::Label *speechLabel; gcn::Label *alphaLabel; @@ -99,7 +104,7 @@ class Setup_Video : public SetupTab, public gcn::ActionListener, int mParticleDetail; gcn::Slider *mParticleDetailSlider; gcn::Label *mParticleDetailField; - + int mFontSize; gcn::DropDown *mFontSizeDropDown; }; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 80c3747e..b8f5b895 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -43,10 +43,10 @@ Image *DropDown::buttons[2][2]; ImageRect DropDown::skin; float DropDown::mAlpha = 1.0; -DropDown::DropDown(gcn::ListModel *listModel, bool deleteModel): +DropDown::DropDown(gcn::ListModel *listModel): gcn::DropDown::DropDown(listModel, new ScrollArea, - new ListBox(listModel, deleteModel)) + new ListBox(listModel)) { setFrameSize(2); diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index eda7b1fa..568e20a5 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -45,7 +45,7 @@ class DropDown : public gcn::DropDown * @param listBox the listBox to use. * @see ListModel, ScrollArea, ListBox. */ - DropDown(gcn::ListModel *listModel = NULL, bool deleteModel = false); + DropDown(gcn::ListModel *listModel = 0); ~DropDown(); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index e97f1d63..a24cf599 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -34,18 +34,13 @@ float ListBox::mAlpha = 1.0; -ListBox::ListBox(gcn::ListModel *listModel, bool deleteModel): - gcn::ListBox(listModel), - mDeleteModel(deleteModel) +ListBox::ListBox(gcn::ListModel *listModel): + gcn::ListBox(listModel) { } ListBox::~ListBox() { - if (mDeleteModel) - { - delete mListModel; - } } void ListBox::updateAlpha() diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index c0662ed2..ed17c6ad 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -39,7 +39,7 @@ class ListBox : public gcn::ListBox /** * Constructor. */ - ListBox(gcn::ListModel *listModel, bool deleteModel = false); + ListBox(gcn::ListModel *listModel); ~ListBox(); @@ -67,8 +67,6 @@ class ListBox : public gcn::ListBox private: static float mAlpha; - - bool mDeleteModel; }; #endif |