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/CoinList.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'pokemod/CoinList.cpp') 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; -- cgit