summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-20 05:26:02 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-20 05:26:02 +0300
commited0f26678c9aa154d3af441762b9a3ad5345747c (patch)
tree69183723af9c8f41fb7a13b62bff84960515e1a1 /src
parent5d4be5df7aaac5186c263caa9354891fec66d1c3 (diff)
downloadmv-ed0f26678c9aa154d3af441762b9a3ad5345747c.tar.gz
mv-ed0f26678c9aa154d3af441762b9a3ad5345747c.tar.bz2
mv-ed0f26678c9aa154d3af441762b9a3ad5345747c.tar.xz
mv-ed0f26678c9aa154d3af441762b9a3ad5345747c.zip
Fix memory leak in char selection dialog.
Diffstat (limited to 'src')
-rw-r--r--src/gui/charselectdialog.cpp1
-rw-r--r--src/net/charhandler.h2
-rw-r--r--src/net/ea/charserverhandler.cpp7
-rw-r--r--src/net/ea/charserverhandler.h2
4 files changed, 12 insertions, 0 deletions
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index 93302e0ff..15d1e6e0e 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -186,6 +186,7 @@ CharSelectDialog::CharSelectDialog(LoginData *data):
CharSelectDialog::~CharSelectDialog()
{
+ Net::getCharHandler()->clear();
}
void CharSelectDialog::action(const gcn::ActionEvent &event)
diff --git a/src/net/charhandler.h b/src/net/charhandler.h
index 72a81684c..848354e96 100644
--- a/src/net/charhandler.h
+++ b/src/net/charhandler.h
@@ -90,6 +90,8 @@ class CharHandler
virtual unsigned int maxSprite() const = 0;
+ virtual void clear() = 0;
+
protected:
CharHandler() :
mSelectedCharacter(0),
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index d71236496..63e267584 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -33,6 +33,7 @@
#include "net/ea/loginhandler.h"
#include "net/ea/eaprotocol.h"
+#include "utils/dtor.h"
#include "utils/gettext.h"
#include "resources/chardb.h"
@@ -184,4 +185,10 @@ void CharServerHandler::processCharDeleteFailed(Net::MessageIn &msg A_UNUSED)
new OkDialog(_("Error"), _("Failed to delete character."));
}
+void CharServerHandler::clear()
+{
+ delete_all(mCharacters);
+ mCharacters.clear();
+}
+
} // namespace Ea
diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h
index bd39781cd..bab941503 100644
--- a/src/net/ea/charserverhandler.h
+++ b/src/net/ea/charserverhandler.h
@@ -78,6 +78,8 @@ class CharServerHandler : public Net::CharHandler
virtual void processCharDeleteFailed(Net::MessageIn &msg);
+ virtual void clear();
+
protected:
virtual void readPlayerData(Net::MessageIn &msg,
Net::Character *character,