From 257ed5604c9a00cb465a59100cb66091d4553909 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Wed, 27 May 2009 15:50:35 +0000 Subject: [PATCH] Merge the following commit from e4: ------------------------------------------------------------------------ r973523 | tmcguire | 2009-05-27 15:41:58 +0200 (Wed, 27 May 2009) | 16 lines Merged revisions 970924 via svnmerge from svn+ssh://tmcguire@svn.kde.org/home/kde/branches/KDE/4.2/kdepim ........ r970924 | tmcguire | 2009-05-21 14:19:57 +0200 (Thu, 21 May 2009) | 10 lines Backport r970921 by tmcguire from trunk to the 4.2 branch: Don't grow the list of the UIDs of messages with changed statuses uncontrollable, which would lead to huge memory consumption and a large kmailrc. Patch by Frank Thieme , thank you! CCBUG: 191753 ........ ------------------------------------------------------------------------ svn path=/branches/kdepim/enterprise/kdepim/; revision=973669 --- kmfoldercachedimap.cpp | 18 ++++++++++-------- kmfoldercachedimap.h | 4 +++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/kmfoldercachedimap.cpp b/kmfoldercachedimap.cpp index 5f633d708..f04d63245 100644 --- a/kmfoldercachedimap.cpp +++ b/kmfoldercachedimap.cpp @@ -297,7 +297,7 @@ void KMFolderCachedImap::readConfig() config->readBoolEntry( "StatusChangedLocally", false ); QStringList uidsChanged = config->readListEntry( "UIDStatusChangedLocally" ); for ( QStringList::iterator it = uidsChanged.begin(); it != uidsChanged.end(); it++ ) { - mUIDsOfLocallyChangedStatuses.append( ( *it ).toUInt() ); + mUIDsOfLocallyChangedStatuses.insert( ( *it ).toUInt() ); } mAnnotationFolderTypeChanged = config->readBoolEntry( "AnnotationFolderTypeChanged", false ); @@ -333,7 +333,7 @@ void KMFolderCachedImap::writeConfig() // StatusChangedLocally is always false, as we use UIDStatusChangedLocally now configGroup.writeEntry( "StatusChangedLocally", false ); QStringList uidsToWrite; - for( QValueList::iterator it = mUIDsOfLocallyChangedStatuses.begin(); + for( std::set::iterator it = mUIDsOfLocallyChangedStatuses.begin(); it != mUIDsOfLocallyChangedStatuses.end(); it++ ) { uidsToWrite.append( QString::number( (*it) ) ); } @@ -960,14 +960,14 @@ void KMFolderCachedImap::serverSyncInternal() // Upload flags, unless we know from the ACL that we're not allowed // to do that or they did not change locally if ( mUserRights <= 0 || ( mUserRights & (KMail::ACLJobs::WriteFlags ) ) ) { - if ( !mUIDsOfLocallyChangedStatuses.isEmpty() || mStatusChangedLocally ) { + if ( !mUIDsOfLocallyChangedStatuses.empty() || mStatusChangedLocally ) { uploadFlags(); break; } else { //kdDebug(5006) << "Skipping flags upload, folder unchanged: " << label() << endl; } } else if ( mUserRights & KMail::ACLJobs::WriteSeenFlag ) { - if ( !mUIDsOfLocallyChangedStatuses.isEmpty() || mStatusChangedLocally ) { + if ( !mUIDsOfLocallyChangedStatuses.empty() || mStatusChangedLocally ) { uploadSeenFlags(); break; } @@ -1421,7 +1421,8 @@ void KMFolderCachedImap::uploadFlags() if( !msg || msg->UID() == 0 ) // Either not a valid message or not one that is on the server yet continue; - if ( mUIDsOfLocallyChangedStatuses.findIndex( msg->UID() ) < 0 && !mStatusChangedLocally ) { + if ( mUIDsOfLocallyChangedStatuses.find( msg->UID() ) != mUIDsOfLocallyChangedStatuses.end() + && !mStatusChangedLocally ) { // This message has not had its status changed locally continue; } @@ -1468,7 +1469,8 @@ void KMFolderCachedImap::uploadSeenFlags() // Either not a valid message or not one that is on the server yet continue; - if ( mUIDsOfLocallyChangedStatuses.findIndex( msg->UID() ) < 0 && !mStatusChangedLocally ) { + if ( mUIDsOfLocallyChangedStatuses.find( msg->UID() ) != mUIDsOfLocallyChangedStatuses.end() + && !mStatusChangedLocally ) { // This message has not had its status changed locally continue; } @@ -1532,7 +1534,7 @@ void KMFolderCachedImap::setStatus( int idx, KMMsgStatus status, bool toggle) const KMMsgBase *msg = getMsgBase( idx ); Q_ASSERT( msg ); if ( msg ) - mUIDsOfLocallyChangedStatuses.append( msg->UID() ); + mUIDsOfLocallyChangedStatuses.insert( msg->UID() ); } void KMFolderCachedImap::setStatus(QValueList& ids, KMMsgStatus status, bool toggle) @@ -1542,7 +1544,7 @@ void KMFolderCachedImap::setStatus(QValueList& ids, KMMsgStatus status, boo const KMMsgBase *msg = getMsgBase( *it ); Q_ASSERT( msg ); if ( msg ) - mUIDsOfLocallyChangedStatuses.append( msg->UID() ); + mUIDsOfLocallyChangedStatuses.insert( msg->UID() ); } } diff --git a/kmfoldercachedimap.h b/kmfoldercachedimap.h index 406b1e866..291f4950e 100644 --- a/kmfoldercachedimap.h +++ b/kmfoldercachedimap.h @@ -47,6 +47,8 @@ #include "cachedimapjob.h" #include "quotajobs.h" +#include + using KMail::FolderJob; using KMail::QuotaInfo; class KMCommand; @@ -549,7 +551,7 @@ private: * uploaded to the server, overwriting the server's notion of the status * of the mails in this folder. */ - QValueList mUIDsOfLocallyChangedStatuses; + std::set mUIDsOfLocallyChangedStatuses; /** * Same as above, but uploads the flags of all mails, even if not all changed.