summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-03-30 23:57:40 +0300
committerAndrei Karas <akaras@inbox.ru>2011-03-31 01:04:53 +0300
commit91a51ec64c35713914b22f2d9a283dc5b4091c12 (patch)
tree0289142a45284514a8981b02601c83ac1039dd5d
parentd629f56517f55d1fd756c4774d9a368d66f615df (diff)
downloadmv-91a51ec64c35713914b22f2d9a283dc5b4091c12.tar.gz
mv-91a51ec64c35713914b22f2d9a283dc5b4091c12.tar.bz2
mv-91a51ec64c35713914b22f2d9a283dc5b4091c12.tar.xz
mv-91a51ec64c35713914b22f2d9a283dc5b4091c12.zip
Fix memory leaks and some other errors.
-rw-r--r--src/graphicsvertexes.cpp21
-rw-r--r--src/gui/login.cpp5
-rw-r--r--src/gui/login.h2
-rw-r--r--src/gui/widgets/itemcontainer.cpp1
-rw-r--r--src/gui/widgets/tabbedarea.cpp11
-rw-r--r--src/gui/widgets/window.cpp2
-rw-r--r--src/guild.cpp34
-rw-r--r--src/map.cpp2
-rw-r--r--src/resources/colordb.cpp3
-rw-r--r--src/resources/mapdb.cpp3
10 files changed, 64 insertions, 20 deletions
diff --git a/src/graphicsvertexes.cpp b/src/graphicsvertexes.cpp
index 6beb41a88..7242269f2 100644
--- a/src/graphicsvertexes.cpp
+++ b/src/graphicsvertexes.cpp
@@ -54,12 +54,27 @@ OpenGLGraphicsVertexes::~OpenGLGraphicsVertexes()
void OpenGLGraphicsVertexes::clear()
{
- delete_all(mFloatTexPool);
+ for(std::vector<GLfloat*>::iterator it = mFloatTexPool.begin();
+ it != mFloatTexPool.end(); ++ it)
+ {
+ delete [] (*it);
+ }
mFloatTexPool.clear();
- delete_all(mIntVertPool);
+
+ for(std::vector<GLint*>::iterator it = mIntVertPool.begin();
+ it != mIntVertPool.end(); ++ it)
+ {
+ delete [] (*it);
+ }
mIntVertPool.clear();
- delete_all(mIntTexPool);
+
+ for(std::vector<GLint*>::iterator it = mIntTexPool.begin();
+ it != mIntTexPool.end(); ++ it)
+ {
+ delete [] (*it);
+ }
mIntTexPool.clear();
+
mVp.clear();
}
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index 853276dca..d910d37bc 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -106,7 +106,8 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName,
mKeepCheck = new CheckBox(_("Remember username"), mLoginData->remember);
mUpdateTypeLabel = new Label(_("Update:"));
- mUpdateTypeDropDown = new DropDown(new UpdateTypeModel());
+ mUpdateTypeModel = new UpdateTypeModel();
+ mUpdateTypeDropDown = new DropDown(mUpdateTypeModel);
mUpdateTypeDropDown->setActionEventId("updatetype");
mUpdateTypeDropDown->setSelected((loginData->updateType
| LoginData::Upd_Custom) ^ LoginData::Upd_Custom);
@@ -161,6 +162,8 @@ LoginDialog::LoginDialog(LoginData *loginData, std::string serverName,
LoginDialog::~LoginDialog()
{
+ delete mUpdateTypeModel;
+ mUpdateTypeModel = 0;
}
void LoginDialog::action(const gcn::ActionEvent &event)
diff --git a/src/gui/login.h b/src/gui/login.h
index 49d1aa199..9a65e9718 100644
--- a/src/gui/login.h
+++ b/src/gui/login.h
@@ -33,6 +33,7 @@
#include <vector>
class LoginData;
+class UpdateTypeModel;
/**
* The login dialog.
@@ -86,6 +87,7 @@ class LoginDialog : public Window, public gcn::ActionListener,
LoginData *mLoginData;
std::string *mUpdateHost;
+ UpdateTypeModel *mUpdateTypeModel;
};
#endif
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index c9f1269aa..b76385f03 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -130,6 +130,7 @@ ItemContainer::~ItemContainer()
}
delete mItemPopup;
mItemPopup = 0;
+ delete []mShowMatrix;
}
void ItemContainer::logic()
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp
index f4b4a78f8..6b90cb381 100644
--- a/src/gui/widgets/tabbedarea.cpp
+++ b/src/gui/widgets/tabbedarea.cpp
@@ -46,13 +46,10 @@ TabbedArea::TabbedArea() : gcn::TabbedArea(),
TabbedArea::~TabbedArea()
{
- if (!mEnableScrollButtons)
- {
- delete mArrowButton[0];
- mArrowButton[0] = 0;
- delete mArrowButton[1];
- mArrowButton[1] = 0;
- }
+ delete mArrowButton[0];
+ mArrowButton[0] = 0;
+ delete mArrowButton[1];
+ mArrowButton[1] = 0;
}
void TabbedArea::enableScrollButtons(bool enable)
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 22daa5dc9..3531ac245 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -106,6 +106,8 @@ Window::~Window()
while (!mWidgets.empty())
delete mWidgets.front();
+ mWidgets.clear();
+
// need mWidgets.clean ?
removeWidgetListener(this);
diff --git a/src/guild.cpp b/src/guild.cpp
index 726749b7a..21c066070 100644
--- a/src/guild.cpp
+++ b/src/guild.cpp
@@ -150,6 +150,7 @@ void Guild::removeMember(GuildMember *member)
{
mMembers.erase(itr);
delete *itr;
+ return;
}
++itr;
}
@@ -157,25 +158,42 @@ void Guild::removeMember(GuildMember *member)
void Guild::removeMember(int id)
{
+ bool deleted = true;
MemberList::iterator itr = mMembers.begin(),
itr_end = mMembers.end();
- while (itr != itr_end)
+ while (deleted)
{
- if ((*itr)->mId == id)
- mMembers.erase(itr);
- ++itr;
+ deleted = false;
+ while (itr != itr_end)
+ {
+ if ((*itr)->mId == id)
+ {
+ mMembers.erase(itr);
+ deleted = true;
+ break;
+ }
+ ++itr;
+ }
}
}
void Guild::removeMember(const std::string &name)
{
+ bool deleted = true;
MemberList::iterator itr = mMembers.begin(),
itr_end = mMembers.end();
- while (itr != itr_end)
+ while (deleted)
{
- if ((*itr)->getName() == name)
- mMembers.erase(itr);
- ++itr;
+ while (itr != itr_end)
+ {
+ if ((*itr)->getName() == name)
+ {
+ mMembers.erase(itr);
+ deleted = true;
+ break;
+ }
+ ++itr;
+ }
}
}
diff --git a/src/map.cpp b/src/map.cpp
index bc8102cbd..d0f032b4b 100644
--- a/src/map.cpp
+++ b/src/map.cpp
@@ -1716,7 +1716,7 @@ ObjectsLayer::ObjectsLayer(unsigned width, unsigned height) :
ObjectsLayer::~ObjectsLayer()
{
- delete mTiles;
+ delete [] mTiles;
mTiles = 0;
}
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index 5706c952c..30d7c4f0c 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -98,7 +98,10 @@ void ColorDB::loadColorLists()
XML::Document *doc = new XML::Document("itemcolors.xml");
xmlNodePtr root = doc->rootNode();
if (!root)
+ {
+ delete doc;
return;
+ }
for_each_xml_child_node(node, root)
{
diff --git a/src/resources/mapdb.cpp b/src/resources/mapdb.cpp
index 4050a5072..0b553e35d 100644
--- a/src/resources/mapdb.cpp
+++ b/src/resources/mapdb.cpp
@@ -45,7 +45,10 @@ void MapDB::load()
xmlNodePtr root = doc->rootNode();
if (!root)
+ {
+ delete doc;
return;
+ }
for_each_xml_child_node(node, root)
{