summaryrefslogtreecommitdiffstats
path: root/pokemod/CoinList.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/CoinList.cpp
parent9a65bc6bb7c8da1dfa5b101579e52845c75848ef (diff)
[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/CoinList.cpp')
-rw-r--r--pokemod/CoinList.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp
index c0e83a59..0b0ff46b 100644
--- a/pokemod/CoinList.cpp
+++ b/pokemod/CoinList.cpp
@@ -50,8 +50,8 @@ CoinList::CoinList(const Pokemod* pokemod, const QString& fileName, const int id
CoinList::~CoinList()
{
- foreach (CoinListObject* object, m_objects)
- delete object;
+ while (objectCount())
+ deleteObject(0);
}
bool CoinList::validate() const
@@ -124,7 +124,8 @@ void CoinList::load(const QString& fileName, int id) throw(Exception)
QStringList path = pokemod()->path().split('/');
path.removeLast();
QDir fdir(path.join("/"));
- m_objects.clear();
+ while (objectCount())
+ deleteObject(0);
if (fdir.cd("item"))
{
QStringList files(fdir.entryList(QStringList("*.pini"), QDir::Files, QDir::Name));
@@ -260,7 +261,8 @@ CoinList& CoinList::operator=(const CoinList& rhs)
if (this == &rhs)
return *this;
m_name = rhs.m_name;
- m_objects.clear();
+ while (objectCount())
+ deleteObject(0);
foreach (CoinListObject* object, rhs.m_objects)
m_objects.append(new CoinListObject(pokemod(), *object, object->id()));
return *this;