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

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

SVN commit 953982 by djarvie:

Fix undo/redo memory leak


 M  +5 -3      autodeletelist.h  


--- trunk/KDE/kdepim/kalarm/lib/autodeletelist.h #953981:953982
@@ -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