From 12d5161318a4d8d781f896812f5a95fa7b46d8a8 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 31 Mar 2008 02:07:25 +0000 Subject: [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 --- pokemod/MapWildList.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'pokemod/MapWildList.cpp') 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; -- cgit