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

List:       kmail-devel
Subject:    Re: [Bug 105391] New: KMail fails to compile with gcc 4.0.1
From:       Mario Teijeiro Otero <emeteo () escomposlinux ! org>
Date:       2005-05-11 22:22:55
Message-ID: 200505120023.02031.emeteo () escomposlinux ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Please, test this patch with your amd64.  According to Stroustrup's book "The 
C++ Programming Language:" Some times it is necesary a reinterpret_cast to 
convert a pointer to a int value.


Regards

["reinterpretcast.diff" (text/x-diff)]

Index: kmacctexppop.cpp
===================================================================
--- kmacctexppop.cpp	(revisión: 412519)
+++ kmacctexppop.cpp	(copia de trabajo)
@@ -63,6 +63,8 @@
   processingDelay = 2*100;
   mProcessing = false;
   dataCounter = 0;
+  mUidsOfSeenMsgsDict.setAutoDelete( false );
+  mUidsOfNextSeenMsgsDict.setAutoDelete( false );
 
   headersOnServer.setAutoDelete(true);
   connect(&processMsgsTimer,SIGNAL(timeout()),SLOT(slotProcessPendingMsgs()));
@@ -157,14 +159,15 @@
     KConfig config( seenUidList );
     QStringList uidsOfSeenMsgs = config.readListEntry( "seenUidList" );
     QValueList<int> timeOfSeenMsgs = config.readIntListEntry( "seenUidTimeList" );
-    mUidsOfSeenMsgsMap.clear();
+    mUidsOfSeenMsgsDict.clear();
+    mUidsOfSeenMsgsDict.resize( KMail::nextPrime( ( uidsOfSeenMsgs.count() * 11 ) / 10 ) );
     int idx = 1;
     for ( QStringList::ConstIterator it = uidsOfSeenMsgs.begin();
           it != uidsOfSeenMsgs.end(); ++it, idx++ ) {
-      // we use mUidsOfSeenMsgsMap to just provide fast random access to the
+      // we use mUidsOfSeenMsgsDict to just provide fast random access to the
       // keys, so we can store the index(+1) that corresponds to the index of
       // mTimeOfSeenMsgsVector for use in KMAcctExpPop::slotData()
-      mUidsOfSeenMsgsMap.insert( *it, idx );
+      mUidsOfSeenMsgsDict.insert( *it, reinterpret_cast<const int *>( idx ) );
     }
     mTimeOfSeenMsgsVector.clear();
     mTimeOfSeenMsgsVector.reserve( timeOfSeenMsgs.size() );
@@ -175,13 +178,13 @@
     // If the counts differ then the config file has presumably been tampered
     // with and so to avoid possible unwanted message deletion we'll treat
     // them all as newly seen by clearing the seen times vector
-    if ( mTimeOfSeenMsgsVector.count() != mUidsOfSeenMsgsMap.count() )
+    if ( mTimeOfSeenMsgsVector.count() != mUidsOfSeenMsgsDict.count() )
       mTimeOfSeenMsgsVector.clear();
     QStringList downloadLater = config.readListEntry( "downloadLater" );
     for ( QStringList::Iterator it = downloadLater.begin(); it != downloadLater.end(); ++it ) {
         mHeaderLaterUids.insert( *it, true );
     }
-    mUidsOfNextSeenMsgsMap.clear();
+    mUidsOfNextSeenMsgsDict.clear();
     mTimeOfNextSeenMsgsMap.clear();
 
     interactive = _interactive;
@@ -305,7 +308,7 @@
     }
     else {
       idsOfMsgsToDelete.append( *curId );
-      mUidsOfNextSeenMsgsMap.insert( *curUid, 1 );
+      mUidsOfNextSeenMsgsDict.insert( *curUid, reinterpret_cast<const int *>( 1 ) );
       mTimeOfNextSeenMsgsMap.insert( *curUid,
         QDateTime::currentDateTime().toTime_t() );
     }
@@ -446,6 +449,9 @@
   QStringList emptyList;
   if (stage == List) {
     kdDebug(5006) << k_funcinfo << "stage == List" << endl;
+    // set the initial size of mUidsOfNextSeenMsgsDict to the number of
+    // messages on the server + 10%
+    mUidsOfNextSeenMsgsDict.resize( KMail::nextPrime( ( idsOfMsgs.count() * 11 ) / 10 ) );
     KURL url = getUrl();
     url.setPath(QString("/uidl"));
     job = KIO::get( url, false, false );
@@ -457,14 +463,14 @@
     mUidlFinished = TRUE;
 
     if ( mLeaveOnServer && mUidForIdMap.isEmpty() &&
-         mUidsOfNextSeenMsgsMap.empty() && !idsOfMsgs.isEmpty() ) {
+         mUidsOfNextSeenMsgsDict.isEmpty() && !idsOfMsgs.isEmpty() ) {
       KMessageBox::sorry(0, i18n("Your POP3 server does not support the UIDL "
       "command: this command is required to determine, in a reliable way, "
       "which of the mails on the server KMail has already seen before;\n"
       "the feature to leave the mails on the server will therefore not "
       "work properly."));
       // An attempt to work around buggy pop servers, these seem to be popular.
-      mUidsOfNextSeenMsgsMap= mUidsOfSeenMsgsMap;
+      mUidsOfNextSeenMsgsDict = mUidsOfSeenMsgsDict;
     }
 
     //check if filter on server
@@ -595,7 +601,8 @@
         }
         if (headersOnServer.current()->action() == Delete) {
           mHeaderDeleteUids.insert(headersOnServer.current()->uid(), true);
-          mUidsOfNextSeenMsgsMap.insert( headersOnServer.current()->uid(), 1 );
+          mUidsOfNextSeenMsgsDict.insert( headersOnServer.current()->uid(),
+                                          reinterpret_cast<const int *>( 1 ) );
           idsOfMsgsToDelete.append(headersOnServer.current()->id());
           mTimeOfNextSeenMsgsMap.insert( headersOnServer.current()->uid(),
                                      QDateTime::currentDateTime().toTime_t() );
@@ -690,7 +697,7 @@
     // remove the uids of all messages which have been deleted
     for ( QStringList::ConstIterator it = idsOfMsgsToDelete.begin();
           it != idsOfMsgsToDelete.end(); ++it ) {
-      mUidsOfNextSeenMsgsMap.remove( mUidForIdMap[*it] );
+      mUidsOfNextSeenMsgsDict.remove( mUidForIdMap[*it] );
     }
     idsOfMsgsToDelete.clear();
     mMailCheckProgressItem->setStatus(
@@ -746,10 +753,10 @@
 
   QStringList uidsOfNextSeenMsgs;
   QValueList<int> seenUidTimeList;
-  QMapIterator<QString,int> it = mUidsOfNextSeenMsgsMap.begin();
-  for( ; it!=mUidsOfNextSeenMsgsMap.end(); ++it ) {
-    uidsOfNextSeenMsgs.append( it.key() );
-    seenUidTimeList.append( mTimeOfNextSeenMsgsMap[it.key()] );
+  QDictIterator<int> it( mUidsOfNextSeenMsgsDict );
+  for( ; it.current(); ++it ) {
+    uidsOfNextSeenMsgs.append( it.currentKey() );
+    seenUidTimeList.append( mTimeOfNextSeenMsgsMap[it.currentKey()] );
   }
   QString seenUidList = locateLocal( "data", "kmail/" + mLogin + ":" + "@" +
                                       mHost + ":" + QString("%1").arg(mPort) );
@@ -853,19 +860,19 @@
     else { // stage == Uidl
       const QString id = qdata.left(spc);
       const QString uid = qdata.mid(spc + 1);
-      if ( mUidsOfSeenMsgsMap.contains( uid ) ) {
+      if ( mUidsOfSeenMsgsDict.find( uid ) != 0 ) {
         if ( mMsgsPendingDownload.contains( id ) ) {
           mMsgsPendingDownload.remove( id );
         }
         else
           kdDebug(5006) << "KMAcctExpPop::slotData synchronization failure." << endl;
         idsOfMsgsToDelete.append( id );
-        mUidsOfNextSeenMsgsMap.insert( uid, 1 );
+        mUidsOfNextSeenMsgsDict.insert( uid, reinterpret_cast<const int *>( 1 ) );
         if ( mTimeOfSeenMsgsVector.empty() )
           mTimeOfNextSeenMsgsMap.insert( uid, time(0) );
         else
           mTimeOfNextSeenMsgsMap.insert( uid,
-            mTimeOfSeenMsgsVector[mUidsOfSeenMsgsMap[uid] - 1] );
+            mTimeOfSeenMsgsVector[reinterpret_cast<int>( mUidsOfSeenMsgsDict[uid] ) - 1] );
       }
       mUidForIdMap.insert( id, uid );
     }
Index: kmacctexppop.h
===================================================================
--- kmacctexppop.h	(revisión: 412519)
+++ kmacctexppop.h	(copia de trabajo)
@@ -131,9 +131,9 @@
   QStringList idsOfMsgs; //used for ids and for count
   QValueList<int> lensOfMsgs;
   QMap<QString, QString> mUidForIdMap; // maps message ID (i.e. index on the server) to UID
-  QMap<QString, int> mUidsOfSeenMsgsMap; // set of UIDs of previously seen messages (for fast lookup)
+  QDict<int> mUidsOfSeenMsgsDict; // set of UIDs of previously seen messages (for fast lookup)
   QValueVector<int> mTimeOfSeenMsgsVector; // list of times of previously seen messages
-  QMap<QString, int> mUidsOfNextSeenMsgsMap; // set of UIDs of seen messages (for the next check)
+  QDict<int> mUidsOfNextSeenMsgsDict; // set of UIDs of seen messages (for the next check)
   QMap<QString, int> mTimeOfNextSeenMsgsMap; // map of uid to times of seen messages
   QStringList idsOfMsgsToDelete;
   int indexOfCurrentMsg;
Index: kmacctimap.cpp
===================================================================
--- kmacctimap.cpp	(revisión: 412519)
+++ kmacctimap.cpp	(copia de trabajo)
@@ -64,11 +64,12 @@
 				   QString("%1").arg(KAccount::id()) );
   KConfig config( serNumUri );
   QStringList serNums = config.readListEntry( "unfiltered" );
+  mFilterSerNumsToSave.setAutoDelete( false );
   
   for ( QStringList::ConstIterator it = serNums.begin();
 	it != serNums.end(); ++it ) {
       mFilterSerNums.append( (*it).toUInt() );
-      mFilterSerNumsToSave.insert( *it, 1 );
+      mFilterSerNumsToSave.insert( *it, reinterpret_cast<const int *>( 1 ) );
     }
 }
 
@@ -82,9 +83,9 @@
 				   QString("%1").arg(KAccount::id()) );
   KConfig config( serNumUri );
   QStringList serNums;
-  QMapIterator<QString,int> it = mFilterSerNumsToSave.begin();
-  for( ; it!=mFilterSerNumsToSave.end(); ++it )
-      serNums.append( it.key() );
+  QDictIterator<int> it( mFilterSerNumsToSave );
+  for( ; it.current(); ++it )
+      serNums.append( it.currentKey() );
   config.writeEntry( "unfiltered", serNums );
 }
 
@@ -548,7 +549,7 @@
   if ( findIt != mFilterSerNums.end() )
       return;
   mFilterSerNums.append( serNum );
-  mFilterSerNumsToSave.insert( QString( "%1" ).arg( serNum ), 1 );
+  mFilterSerNumsToSave.insert( QString( "%1" ).arg( serNum ), reinterpret_cast<const int *>( 1 ) );
 }
 
 int KMAcctImap::slotFilterMsg( KMMessage *msg )
Index: kmacctimap.h
===================================================================
--- kmacctimap.h	(revisión: 412519)
+++ kmacctimap.h	(copia de trabajo)
@@ -23,7 +23,7 @@
 #define KMAcctImap_h
 
 #include "imapaccountbase.h"
-#include <qmap.h>
+#include <qdict.h>
 
 class KMFolderImap;
 class KMFolderTreeItem;
@@ -144,7 +144,7 @@
   QTimer mErrorTimer;
   int mCountRemainChecks;
   QValueList<Q_UINT32> mFilterSerNums;
-  QMap<QString,int> mFilterSerNumsToSave;
+  QDict<int> mFilterSerNumsToSave;
 };
 
 #endif /*KMAcctImap_h*/

[Attachment #8 (application/pgp-signature)]

_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel


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

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