diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-03-10 12:23:50 -0600 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-03-15 13:21:03 -0600 |
commit | d6f89802e5aa32f266e881e43d6005e821040c57 (patch) | |
tree | 8279ca50117fced2dc26f7e6d4bdd7d5694af255 | |
parent | 4b459b50521f5d7a0518e229a20f14ed2f1d22f9 (diff) | |
download | mana-d6f89802e5aa32f266e881e43d6005e821040c57.tar.gz mana-d6f89802e5aa32f266e881e43d6005e821040c57.tar.bz2 mana-d6f89802e5aa32f266e881e43d6005e821040c57.tar.xz mana-d6f89802e5aa32f266e881e43d6005e821040c57.zip |
Fix some mem leaks
-rw-r--r-- | src/beingmanager.cpp | 5 | ||||
-rw-r--r-- | src/beingmanager.h | 4 | ||||
-rw-r--r-- | src/game.cpp | 3 | ||||
-rw-r--r-- | src/gui/chat.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup_colors.cpp | 5 | ||||
-rw-r--r-- | src/gui/skill.cpp | 2 | ||||
-rw-r--r-- | src/gui/table.cpp | 1 | ||||
-rw-r--r-- | src/gui/window.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 1 | ||||
-rw-r--r-- | src/player_relations.cpp | 31 | ||||
-rw-r--r-- | src/player_relations.h | 6 |
12 files changed, 42 insertions, 22 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 0c7a310a..e5836aa7 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -52,6 +52,11 @@ BeingManager::BeingManager(Network *network): { } +BeingManager::~BeingManager() +{ + clear(); +} + void BeingManager::setMap(Map *map) { mMap = map; diff --git a/src/beingmanager.h b/src/beingmanager.h index 472e2c83..3284ce16 100644 --- a/src/beingmanager.h +++ b/src/beingmanager.h @@ -37,6 +37,8 @@ class BeingManager public: BeingManager(Network *network); + ~BeingManager(); + /** * Sets the map on which beings are created */ @@ -113,7 +115,7 @@ class BeingManager void logic(); /** - * Destroys all beings except the local player and current NPC (if any) + * Destroys all beings except the local player */ void clear(); diff --git a/src/game.cpp b/src/game.cpp index 47f4ffd2..a346616f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -204,7 +204,6 @@ void createGuiWindows(Network *network) npcListDialog = new NpcListDialog(network); npcStringDialog = new NpcStringDialog(network); skillDialog = new SkillDialog(); - setupWindow = new Setup(); minimap = new Minimap(); equipmentWindow = new EquipmentWindow(); tradeWindow = new TradeWindow(network); @@ -337,6 +336,8 @@ Game::Game(Network *network): msg.writeInt32(tick_time); engine->changeMap(map_path); + + setupWindow->setInGame(true); } Game::~Game() diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 098d4e46..44e08052 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -109,6 +109,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 ab0b2245..dc232296 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -108,6 +108,8 @@ Setup::Setup(): add(panel); setLocationRelativeTo(getParent()); + + setInGame(false); } Setup::~Setup() diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index 760fdc1f..148fd679 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -62,9 +62,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 64214ff5..9fbae7a6 100644 --- a/src/gui/skill.cpp +++ b/src/gui/skill.cpp @@ -161,7 +161,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 144e7e21..fa801865 100644 --- a/src/gui/table.cpp +++ b/src/gui/table.cpp @@ -99,6 +99,7 @@ GuiTable::GuiTable(TableModel *initial_model, gcn::Color background, GuiTable::~GuiTable(void) { + uninstallActionListeners(); delete mModel; } diff --git a/src/gui/window.cpp b/src/gui/window.cpp index e6e79b45..404f5746 100644 --- a/src/gui/window.cpp +++ b/src/gui/window.cpp @@ -124,6 +124,8 @@ Window::~Window() delete(w); } + removeWidgetListener(this); + instances--; mSkin->instances--; diff --git a/src/main.cpp b/src/main.cpp index 60a4d500..7ee2f6b4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1021,7 +1021,6 @@ int main(int argc, char *argv[]) delete progressBar; delete progressLabel; delete setup; - delete setupWindow; progressBar = NULL; progressLabel = NULL; currentDialog = NULL; diff --git a/src/player_relations.cpp b/src/player_relations.cpp index 1c1ba669..eec4153c 100644 --- a/src/player_relations.cpp +++ b/src/player_relations.cpp @@ -29,6 +29,8 @@ #include "player.h" #include "player_relations.h" +#include "utils/dtor.h" + #define PLAYER_IGNORE_STRATEGY_NOP "nop" #define PLAYER_IGNORE_STRATEGY_EMOTE0 "emote0" #define DEFAULT_IGNORE_STRATEGY PLAYER_IGNORE_STRATEGY_EMOTE0 @@ -38,7 +40,6 @@ #define IGNORE_EMOTE_TIME 100 - // (De)serialisation class class PlayerConfSerialiser : public ConfigurationListManager<std::pair<std::string, PlayerRelation *>, std::map<std::string, PlayerRelation *> *> @@ -93,6 +94,11 @@ PlayerRelationsManager::PlayerRelationsManager() : { } +PlayerRelationsManager::~PlayerRelationsManager() +{ + delete_all(mIgnoreStrategies); +} + void PlayerRelationsManager::clear() { std::vector<std::string> *names = getPlayers(); @@ -351,19 +357,20 @@ static std::vector<PlayerIgnoreStrategy *> player_ignore_strategies; std::vector<PlayerIgnoreStrategy *> * PlayerRelationsManager::getPlayerIgnoreStrategies() { - if (player_ignore_strategies.size() == 0) { + if (mIgnoreStrategies.size() == 0) + { // not initialised yet? - player_ignore_strategies.push_back(new PIS_emote(FIRST_IGNORE_EMOTE, - "floating '...' bubble", - PLAYER_IGNORE_STRATEGY_EMOTE0)); - player_ignore_strategies.push_back(new PIS_emote(FIRST_IGNORE_EMOTE + 1, - "floating bubble", - "emote1")); - player_ignore_strategies.push_back(new PIS_nothing()); - player_ignore_strategies.push_back(new PIS_dotdotdot()); - player_ignore_strategies.push_back(new PIS_blinkname()); + mIgnoreStrategies.push_back(new PIS_emote(FIRST_IGNORE_EMOTE, + "floating '...' bubble", + PLAYER_IGNORE_STRATEGY_EMOTE0)); + mIgnoreStrategies.push_back(new PIS_emote(FIRST_IGNORE_EMOTE + 1, + "floating bubble", + "emote1")); + mIgnoreStrategies.push_back(new PIS_nothing()); + mIgnoreStrategies.push_back(new PIS_dotdotdot()); + mIgnoreStrategies.push_back(new PIS_blinkname()); } - return &player_ignore_strategies; + return &mIgnoreStrategies; } diff --git a/src/player_relations.h b/src/player_relations.h index 0440cace..f4860e08 100644 --- a/src/player_relations.h +++ b/src/player_relations.h @@ -96,6 +96,8 @@ class PlayerRelationsManager public: PlayerRelationsManager(); + ~PlayerRelationsManager(); + /** * Initialise player relations manager (load config file etc.) */ @@ -143,7 +145,6 @@ public: */ void removePlayer(const std::string &name); - /** * Retrieves the default permissions. */ @@ -154,8 +155,6 @@ public: */ void setDefault(unsigned int permissions); - - /** * Retrieves all known player ignore strategies. * @@ -233,6 +232,7 @@ private: PlayerIgnoreStrategy *mIgnoreStrategy; std::map<std::string, PlayerRelation *> mRelations; std::list<PlayerRelationsListener *> mListeners; + std::vector<PlayerIgnoreStrategy *> mIgnoreStrategies; }; |