Message: previous - next
Month: April 2012

tdepim - gcc47 - need help with "which redeclared 'it' is right 'it'?"

From: "David C. Rankin" <drankinatty@...>
Date: Wed, 18 Apr 2012 16:39:44 -0500
Calvin, Slavek, Liddell,

   I'm trying to fix tdepim to build with gcc47, but I don't understand how to 
make sure I'm fixing the right 'it' iterator. Specifically, the multiple 
declaration issue is:

/build/src/tdepim/kmail/kmsystemtray.cpp: In member function 'void 
/build/src/tdepim/kmail/kmsystemtray.cpp:485:48: error: redeclaration of 
'TQMap<TQGuardedPtr<KMFolder>, int>::Iterator it'
/build/src/tdepim/kmail/kmsystemtray.cpp:475:55: error: 
'TQMap<TQGuardedPtr<KMFolder>, bool>::Iterator it' previously declared here

   The code beginning at line 473 is:

void KMSystemTray::updateNewMessages()
   for ( TQMap<TQGuardedPtr<KMFolder>, bool>::Iterator it = 
         it != mPendingUpdates.end(); ++it)
   KMFolder *fldr = it.key();
   if ( !fldr ) // deleted folder

   /** The number of unread messages in that folder */
   int unread = fldr->countUnread();

   TQMap<TQGuardedPtr<KMFolder>, int>::Iterator it =
   bool unmapped = (it == mFoldersWithUnread.end());

   /** If the folder is not mapped yet, increment count by numUnread
       in folder */
   if(unmapped) mCount += unread;
   /* Otherwise, get the difference between the numUnread in the folder and
    * our last known version, and adjust mCount with that difference */
     int diff = unread -;
     mCount += diff;

   Looking through the comments and context, there seems to be two 'it' 
iterators involved:

TQMap<.., bool>
TQMap<.., int>

with the 'bool' declaration being the loop index and the 'int' being used to 
determine if the folder with unread messages is unmapped. The 'bool' dec seems 
to be the one used to access the class data (i.e. it.key(), If I'm 
reading that correctly, then we can correct the 'int' iterator by renaming it 
something like 'unread_it'

   TQMap<TQGuardedPtr<KMFolder>, int>::Iterator unread_it =
   bool unmapped = (unread_it == mFoldersWithUnread.end());

   What say the experts. Is my reading of which 'it' can be renamed correct?

David C. Rankin, J.D.,P.E.