summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-03-10 12:23:50 -0600
committerJared Adams <jaxad0127@gmail.com>2009-03-10 12:23:50 -0600
commit17f9d5abcb05da185486ccfba293f3a8c9eab437 (patch)
tree7545a7bdd3acefc1ff92f345416872c896b90ddb /src
parent4a08d3b4bec3fa0fc1878140b0f14c8b38d6420b (diff)
downloadmana-client-17f9d5abcb05da185486ccfba293f3a8c9eab437.tar.gz
mana-client-17f9d5abcb05da185486ccfba293f3a8c9eab437.tar.bz2
mana-client-17f9d5abcb05da185486ccfba293f3a8c9eab437.tar.xz
mana-client-17f9d5abcb05da185486ccfba293f3a8c9eab437.zip
Fix some mem leaks
Diffstat (limited to 'src')
-rw-r--r--src/beingmanager.cpp5
-rw-r--r--src/beingmanager.h4
-rw-r--r--src/game.cpp5
-rw-r--r--src/gui/chat.cpp2
-rw-r--r--src/gui/setup.cpp11
-rw-r--r--src/gui/setup.h4
-rw-r--r--src/gui/setup_colors.cpp5
-rw-r--r--src/gui/skill.cpp2
-rw-r--r--src/gui/table.cpp1
-rw-r--r--src/gui/window.cpp2
-rw-r--r--src/main.cpp1
-rw-r--r--src/player_relations.cpp24
-rw-r--r--src/player_relations.h2
13 files changed, 48 insertions, 20 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp
index 73fa683a..23d91526 100644
--- a/src/beingmanager.cpp
+++ b/src/beingmanager.cpp
@@ -54,6 +54,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 6c0e0fda..d0690798 100644
--- a/src/beingmanager.h
+++ b/src/beingmanager.h
@@ -36,6 +36,8 @@ class BeingManager
public:
BeingManager(Network *network);
+ ~BeingManager();
+
/**
* Sets the map on which beings are created
*/
@@ -112,7 +114,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 74a52ddf..ae708adf 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);
@@ -341,11 +340,12 @@ Game::Game(Network *network):
msg.writeInt32(tick_time);
engine->changeMap(map_path);
+
+ setupWindow->setInGame(true);
}
Game::~Game()
{
- delete player_node;
destroyGuiWindows();
delete beingManager;
@@ -353,6 +353,7 @@ Game::~Game()
delete joystick;
delete particleEngine;
delete engine;
+ delete player_node;
beingManager = NULL;
floorItemManager = NULL;
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 8ecb5f63..55bc2696 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -108,6 +108,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 148e8b75..62d79d4d 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -64,9 +64,9 @@ Setup::Setup():
btn->setPosition(x, height - btn->getHeight() - 5);
add(btn);
- // Disable this button when the windows aren't created yet
+ // Store this button, as it needs to be enabled/disabled
if (!strcmp(*curBtn, "Reset Windows"))
- btn->setEnabled(statusWindow != NULL);
+ mResetWindows = btn;
}
TabbedArea *panel = new TabbedArea;
@@ -101,6 +101,8 @@ Setup::Setup():
add(panel);
setLocationRelativeTo(getParent());
+
+ setInGame(false);
}
Setup::~Setup()
@@ -140,3 +142,8 @@ void Setup::action(const gcn::ActionEvent &event)
tradeWindow->resetToDefaultSize();
}
}
+
+void Setup::setInGame(bool inGame)
+{
+ mResetWindows->setEnabled(inGame);
+} \ No newline at end of file
diff --git a/src/gui/setup.h b/src/gui/setup.h
index e4eb0902..075c88bf 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -31,6 +31,7 @@
#include "../guichanfwd.h"
class SetupTab;
+class Button;
/**
* The setup dialog.
@@ -50,6 +51,8 @@ class Setup : public Window, public gcn::ActionListener
*/
~Setup();
+ void setInGame(bool inGame);
+
/**
* Event handling method.
*/
@@ -57,6 +60,7 @@ class Setup : public Window, public gcn::ActionListener
private:
std::list<SetupTab*> mTabs;
+ gcn::Button *mResetWindows;
};
#endif
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index 49c99996..2610be03 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -57,9 +57,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 61bb9ce9..6112f0e3 100644
--- a/src/gui/skill.cpp
+++ b/src/gui/skill.cpp
@@ -163,7 +163,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 1371a78e..274f9a48 100644
--- a/src/gui/table.cpp
+++ b/src/gui/table.cpp
@@ -98,6 +98,7 @@ GuiTable::GuiTable(TableModel *initial_model, gcn::Color background,
GuiTable::~GuiTable()
{
+ uninstallActionListeners();
delete mModel;
}
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index 8eaaf31d..be63ff21 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -142,6 +142,8 @@ Window::~Window()
delete(w);
}
+ removeWidgetListener(this);
+
instances--;
// Clean up static resources
diff --git a/src/main.cpp b/src/main.cpp
index 2c2ff0b6..06093946 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1027,7 +1027,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 c82876e1..14df3f01 100644
--- a/src/player_relations.cpp
+++ b/src/player_relations.cpp
@@ -28,6 +28,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
@@ -37,7 +39,6 @@
#define IGNORE_EMOTE_TIME 100
-
// (De)serialisation class
class PlayerConfSerialiser : public ConfigurationListManager<std::pair<std::string, PlayerRelation *>,
std::map<std::string, PlayerRelation *> *>
@@ -92,6 +93,11 @@ PlayerRelationsManager::PlayerRelationsManager() :
{
}
+PlayerRelationsManager::~PlayerRelationsManager()
+{
+ delete_all(mIgnoreStrategies);
+}
+
void PlayerRelationsManager::clear()
{
std::vector<std::string> *names = getPlayers();
@@ -345,24 +351,22 @@ private:
-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,
+ mIgnoreStrategies.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,
+ mIgnoreStrategies.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_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 1eb4ede6..dd363d41 100644
--- a/src/player_relations.h
+++ b/src/player_relations.h
@@ -94,6 +94,7 @@ class PlayerRelationsManager
{
public:
PlayerRelationsManager();
+ ~PlayerRelationsManager();
/**
* Initialise player relations manager (load config file etc.)
@@ -232,6 +233,7 @@ private:
PlayerIgnoreStrategy *mIgnoreStrategy;
std::map<std::string, PlayerRelation *> mRelations;
std::list<PlayerRelationsListener *> mListeners;
+ std::vector<PlayerIgnoreStrategy *> mIgnoreStrategies;
};