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

List:       kde-commits
Subject:    branches/KDE/3.5/kdepim/libkcal
From:       David Jarvie <software () astrojar ! org ! uk>
Date:       2005-08-21 22:07:24
Message-ID: 1124662044.299895.4794.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 451825 by djarvie:

Fix qSortUnique(): iterator error after removal of item, and erroneous removal of default T if first item


 M  +9 -3      recurrencerule.h  


--- branches/KDE/3.5/kdepim/libkcal/recurrencerule.h #451824:451825
@@ -33,13 +33,19 @@
 Q_INLINE_TEMPLATES void qSortUnique( QValueList<T> &lst )
 {
   qHeapSort( lst );
+  if ( lst.isEmpty() ) return;
   // Remove all duplicates from the times list
   // TODO: Make this more efficient!
-  T last, newlast;
-  for ( QValueListIterator<T> it = lst.begin(); it != lst.end(); ++it ) {
+  QValueListIterator<T> it = lst.begin();
+  T last = *it++;
+  T newlast;
+  while ( it != lst.end() ) {
     newlast = (*it);
     if ( newlast == last ) it = lst.remove( it );
-    last = newlast;
+    else {
+      last = newlast;
+      ++it;
+    }
   }
 }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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