[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/KDE/4.2/kdepim/kalarm/lib
From:       David Jarvie <software () astrojar ! org ! uk>
Date:       2009-04-14 21:08:53
Message-ID: 1239743333.809160.6576.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 953980 by djarvie:

Fix undo/redo memory leak


 M  +5 -3      autodeletelist.h  


--- branches/KDE/4.2/kdepim/kalarm/lib/autodeletelist.h #953979:953980
@@ -1,7 +1,7 @@
 /*
  *  autodeletelist.h  -  pointer list with auto-delete on destruction
  *  Program:  kalarm
- *  Copyright  © 2008 by David Jarvie <software@astrojar.org.uk>
+ *  Copyright  © 2008,2009 by David Jarvie <djarvie@kde.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -36,8 +36,10 @@
 		AutoDeleteList() : QList<T*>() {}
 		~AutoDeleteList()
 		{
-			for (int i = 0, end = QList<T*>::count();  i < end;  ++i)
-				delete QList<T*>::operator[](i);
+			// Remove from list first before deleting the pointer, in
+			// case the pointer's destructor removes it from the list.
+			while (!this->isEmpty())
+				delete this->takeFirst();
 		}
 	private:
 		// Prevent copying since that would create two owners of the pointers
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic