diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-03-31 02:07:25 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-03-31 02:07:25 +0000 |
| commit | 12d5161318a4d8d781f896812f5a95fa7b46d8a8 (patch) | |
| tree | 70617a790b791b876426d85848d20901e65d6606 /pokemod/Ability.cpp | |
| parent | 9a65bc6bb7c8da1dfa5b101579e52845c75848ef (diff) | |
| download | sigen-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/Ability.cpp')
| -rw-r--r-- | pokemod/Ability.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp index ee2feeea..88dab692 100644 --- a/pokemod/Ability.cpp +++ b/pokemod/Ability.cpp @@ -47,8 +47,8 @@ Ability::Ability(const Pokemod* pokemod, const QString& fileName, const int id) Ability::~Ability() { - foreach (AbilityEffect* effect, m_effects) - delete effect; + while (effectCount()) + deleteEffect(0); } bool Ability::validate() const @@ -90,7 +90,8 @@ void Ability::load(const QString& fileName, int id) throw(Exception) QStringList path = pokemod()->path().split('/'); path.removeLast(); QDir fdir(path.join("/")); - m_effects.clear(); + while (effectCount()) + deleteEffect(0); if (fdir.cd("effect")) { QStringList files(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name)); @@ -202,7 +203,8 @@ Ability& Ability::operator=(const Ability& rhs) if (this == &rhs) return *this; m_name = rhs.m_name; - m_effects.clear(); + while (effectCount()) + deleteEffect(0); foreach (AbilityEffect* effect, rhs.m_effects) m_effects.append(new AbilityEffect(pokemod(), *effect, effect->id())); return *this; |
