summaryrefslogtreecommitdiffstats
path: root/pokemod/MapWildList.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-03-31 02:07:25 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-03-31 02:07:25 +0000
commit12d5161318a4d8d781f896812f5a95fa7b46d8a8 (patch)
tree70617a790b791b876426d85848d20901e65d6606 /pokemod/MapWildList.cpp
parent9a65bc6bb7c8da1dfa5b101579e52845c75848ef (diff)
downloadsigen-12d5161318a4d8d781f896812f5a95fa7b46d8a8.tar.gz
sigen-12d5161318a4d8d781f896812f5a95fa7b46d8a8.tar.xz
sigen-12d5161318a4d8d781f896812f5a95fa7b46d8a8.zip
[FIX] Memory leaks in load and copy method
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@96 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/MapWildList.cpp')
-rw-r--r--pokemod/MapWildList.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/pokemod/MapWildList.cpp b/pokemod/MapWildList.cpp
index 59ccec3f..0f6730e7 100644
--- a/pokemod/MapWildList.cpp
+++ b/pokemod/MapWildList.cpp
@@ -52,8 +52,8 @@ MapWildList::MapWildList(const Pokemod* pokemod, const QString& fileName, const
MapWildList::~MapWildList()
{
- foreach (MapWildListEncounter* encounter, m_encounters)
- delete encounter;
+ while (encounterCount())
+ deleteEncounter(0);
}
bool MapWildList::validate() const
@@ -155,7 +155,8 @@ void MapWildList::load(const QString& fileName, int id) throw(Exception)
QStringList path = pokemod()->path().split('/');
path.removeLast();
QDir fdir(path.join("/"));
- m_encounters.clear();
+ while (encounterCount())
+ deleteEncounter(0);
if (fdir.cd("encounter"))
{
QStringList files(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name));
@@ -345,7 +346,8 @@ MapWildList& MapWildList::operator=(const MapWildList& rhs)
m_value = rhs.m_value;
m_times = rhs.m_times;
m_scope = rhs.m_scope;
- m_encounters.clear();
+ while (encounterCount())
+ deleteEncounter(0);
foreach (MapWildListEncounter* encounter, rhs.m_encounters)
m_encounters.append(new MapWildListEncounter(pokemod(), *encounter, encounter->id()));
return *this;