diff options
author | Andrei Karas <akaras@inbox.ru> | 2010-06-06 16:08:19 +0300 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2010-06-06 17:09:22 +0200 |
commit | b4a8d4b0db33d074df0d7489e52f64964b2bf8ca (patch) | |
tree | 82d798ce297a21f684c21e5cedbc6471c518e7c2 /src | |
parent | ece8fcdd4a17000285052941148afa056e0a40b7 (diff) | |
download | mana-b4a8d4b0db33d074df0d7489e52f64964b2bf8ca.tar.gz mana-b4a8d4b0db33d074df0d7489e52f64964b2bf8ca.tar.bz2 mana-b4a8d4b0db33d074df0d7489e52f64964b2bf8ca.tar.xz mana-b4a8d4b0db33d074df0d7489e52f64964b2bf8ca.zip |
Fix memory leak in setup_players
Reviewed-by: Thorbjørn Lindeijer
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/setup_players.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 06bae0ef..802a5b2e 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -35,6 +35,7 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/table.h" +#include "utils/dtor.h" #include "utils/gettext.h" #include <string> @@ -88,7 +89,8 @@ class PlayerTableModel : public TableModel { public: PlayerTableModel() : - mPlayers(NULL) + mPlayers(NULL), + mListModel(new PlayerRelationListModel) { playerRelationsUpdated(); } @@ -96,6 +98,7 @@ public: virtual ~PlayerTableModel() { freeWidgets(); + delete mListModel; if (mPlayers) delete mPlayers; } @@ -139,9 +142,8 @@ public: std::string name = (*player_names)[r]; gcn::Widget *widget = new Label(name); mWidgets.push_back(widget); - gcn::ListModel *playerRelation = new PlayerRelationListModel; - gcn::DropDown *choicebox = new DropDown(playerRelation); + gcn::DropDown *choicebox = new DropDown(mListModel); choicebox->setSelected(player_relations.getRelation(name)); mWidgets.push_back(choicebox); } @@ -170,12 +172,7 @@ public: delete mPlayers; mPlayers = NULL; - for (std::vector<gcn::Widget *>::const_iterator it = mWidgets.begin(); - it != mWidgets.end(); it++) - { - delete *it; - } - + delete_all(mWidgets); mWidgets.clear(); } @@ -187,6 +184,7 @@ public: protected: std::vector<std::string> *mPlayers; std::vector<gcn::Widget *> mWidgets; + PlayerRelationListModel *mListModel; }; /** |