--===============1598086927== Content-Type: multipart/signed; boundary="nextPart3013829.ar9hvgpEXe"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart3013829.ar9hvgpEXe Content-Type: multipart/mixed; boundary="Boundary-01=_0/vXCYVOJOnNQBY" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_0/vXCYVOJOnNQBY Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, I am with dimap and my imap server reside on the lan. I notice that a=20 "Refresh cache" or a checking mail with a lot of new messages eat the 100% = of=20 cpu. I found that the problems is related with the gui refresh, because the gui= is=20 refreshed with each mail that arrives ( kmheaders, kmfoldertree and=20 statusBar ). With a suggestion of Till I compress the signals "msgAdded" in =46olderStorage::emitMsgAddedSigals getting good results, I did the same wi= th=20 the signal numUnreadMsgsChanged because this is connected with the refresh = of=20 status bar.=20 =09 With this patch, the CPU keeps at 40% when the cache is refresh when befor= e=20 raise to 100%. Please, have a look and test it. it likes works fine and don't broke=20 anything (to me), but only god knows.=20 Regards --Boundary-01=_0/vXCYVOJOnNQBY Content-Type: text/x-diff; charset="iso-8859-15"; name="emits_delayed.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="emits_delayed.diff" ? .folderstorage.cpp.swp ? .kmfoldercachedimap.cpp.swp ? .kmmainwin.rc.swp ? .kmreadermainwin.rc.swp ? pics/quotecollapse.png ? pics/quoteexpand.png Index: cachedimapjob.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdepim/kmail/cachedimapjob.cpp,v retrieving revision 1.63 diff -u -p -r1.63 cachedimapjob.cpp =2D-- cachedimapjob.cpp 8 Mar 2005 14:43:35 -0000 1.63 +++ cachedimapjob.cpp 14 Apr 2005 23:21:30 -0000 @@ -290,9 +290,11 @@ void CachedImapJob::slotGetNextMessage(K mSentBytes +=3D size; emit progress( mSentBytes, mTotalBytes ); mAccount->removeJob(it); =2D } + } else + mFolder->quiet( true ); =20 if( mMsgsForDownload.isEmpty() ) { + mFolder->quiet( false ); delete this; return; } Index: folderstorage.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdepim/kmail/folderstorage.cpp,v retrieving revision 1.49 diff -u -p -r1.49 folderstorage.cpp =2D-- folderstorage.cpp 31 Mar 2005 20:37:53 -0000 1.49 +++ folderstorage.cpp 14 Apr 2005 23:21:34 -0000 @@ -61,7 +61,7 @@ using KMail::ListJob; //------------------------------------------------------------------------= =2D---- =20 FolderStorage::FolderStorage( KMFolder* folder, const char* aName ) =2D : QObject( folder, aName ), mFolder( folder ) + : QObject( folder, aName ), mFolder( folder ), mQuietTimer( 0L ) { mOpenCount =3D 0; mQuiet =3D 0; @@ -82,6 +82,7 @@ FolderStorage::FolderStorage( KMFolder*=20 mDirtyTimer =3D new QTimer(this); connect(mDirtyTimer, SIGNAL(timeout()), this, SLOT(updateIndex())); + =20 mHasChildren =3D HasNoChildren; mContentsType =3D KMail::ContentsTypeMail; } @@ -192,15 +193,32 @@ void FolderStorage::markUnreadAsRead() //------------------------------------------------------------------------= =2D---- void FolderStorage::quiet(bool beQuiet) { + if (beQuiet) + { + /* Allocate the timer here to don't have one timer for each folder. BT= W, + * a timer is created when a folder is checked + */ + if ( !mQuietTimer ) {=20 + mQuietTimer =3D new QTimer( this ); + connect( mQuietTimer, SIGNAL( timeout() ), + this, SLOT( slotQuietTimer() ) ); + } mQuiet++; =2D else { + } else { mQuiet--; if (mQuiet <=3D 0) { + delete mQuietTimer; + mQuietTimer=3D0L; + mQuiet =3D 0; =2D if (mChanged) + if (mChanged) { emit changed(); + // Don't hurt emit this if the mUnreadMsg really don't change + // We emit it here, because this signal is delayed if mQuite >0 + emit numUnreadMsgsChanged( folder() ); + } mChanged =3D FALSE; } } @@ -245,6 +263,13 @@ int FolderStorage::expungeOldMsg(int day return msgnb; } =20 +//------------------------------------------ +void FolderStorage::slotQuietTimer() +{ + kdDebug(5006) << "FolderStorage::slotQuietTimer()" << endl; + emit changed(); + mChanged=3Dfalse; +} //------------------------------------------------------------------------= =2D---- void FolderStorage::emitMsgAddedSignals(int idx) { @@ -252,6 +277,11 @@ void FolderStorage::emitMsgAddedSignals( if (!mQuiet) { emit msgAdded(idx); } else { + /** Restart always the timer or not. BTW we get a kmheaders refresh + * each 3 seg.?*/ + if ( !mQuietTimer->isActive() ) { + mQuietTimer->start( 3000 ); + } mChanged=3Dtrue; } emit msgAdded( folder(), serNum ); @@ -359,7 +389,16 @@ void FolderStorage::removeMsg(int idx, b if (mb->isUnread() || mb->isNew() || (folder() =3D=3D kmkernel->outboxFolder())) { --mUnreadMsgs; =2D emit numUnreadMsgsChanged( folder() ); + if ( !mQuiet ) { +// kdDebug( 5006 ) << "FolderStorage::msgStatusChanged" << endl; + emit numUnreadMsgsChanged( folder() ); + }else{ + if ( !mQuietTimer->isActive() ) { + kdDebug( 5006 )<< "QuietTimer started" << endl; + mQuietTimer->start( 3000 ); + } + mChanged =3D true; + } } --mTotalMsgs; =20 @@ -388,7 +427,16 @@ KMMessage* FolderStorage::take(int idx) if (msg->isUnread() || msg->isNew() || ( folder() =3D=3D kmkernel->outboxFolder() )) { --mUnreadMsgs; =2D emit numUnreadMsgsChanged( folder() ); + if ( !mQuiet ) { + kdDebug( 5006 ) << "FolderStorage::msgStatusChanged" << endl; + emit numUnreadMsgsChanged( folder() ); + }else{ + if ( !mQuietTimer->isActive() ) { + kdDebug( 5006 )<< "QuietTimer started" << endl; + mQuietTimer->start( 3000 ); + } + mChanged =3D true; + } } --mTotalMsgs; msg->setParent(0); @@ -800,10 +848,16 @@ void FolderStorage::msgStatusChanged(con if (deltaUnread !=3D 0) { if (mUnreadMsgs < 0) mUnreadMsgs =3D 0; mUnreadMsgs +=3D deltaUnread; =2D if ( !mQuiet ) + if ( !mQuiet ) { + kdDebug( 5006 ) << "FolderStorage::msgStatusChanged" << endl; emit numUnreadMsgsChanged( folder() ); =2D else + }else{ + if ( !mQuietTimer->isActive() ) { + kdDebug( 5006 )<< "QuietTimer started" << endl; + mQuietTimer->start( 3000 ); + } mChanged =3D true; + } Q_UINT32 serNum =3D kmkernel->msgDict()->getMsgSerNum(folder(), idx); emit msgChanged( folder(), serNum, deltaUnread ); } @@ -816,8 +870,14 @@ void FolderStorage::headerOfMsgChanged(c idx =3D aMsg->parent()->find( aMsg ); if (idx >=3D 0 && !mQuiet) emit msgHeaderChanged(folder(), idx); =2D else + else{ + if ( !mQuietTimer->isActive() ) { + kdDebug( 5006 )<< "QuietTimer started" << endl; + mQuietTimer->start( 3000 ); + } + mChanged =3D true; + } } =20 //------------------------------------------------------------------------= =2D---- @@ -860,6 +920,7 @@ void FolderStorage::correctUnreadMsgsCou { open(); close(); + kdDebug( 5006 ) << "FolderStorage::correctUnreadMsgsCount" << endl; emit numUnreadMsgsChanged( folder() ); } =20 Index: folderstorage.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdepim/kmail/folderstorage.h,v retrieving revision 1.43 diff -u -p -r1.43 folderstorage.h =2D-- folderstorage.h 16 Feb 2005 20:13:19 -0000 1.43 +++ folderstorage.h 14 Apr 2005 23:21:35 -0000 @@ -507,6 +507,8 @@ public slots: /** Add a copy of the message to the folder after it has been retrieved from an IMAP server */ virtual void reallyAddCopyOfMsg(KMMessage* aMsg); + /** */ + void slotQuietTimer(); =20 protected slots: virtual void removeJob( QObject* ); @@ -592,6 +594,8 @@ protected: =20 KMFolder* mFolder; =20 + QTimer * mQuietTimer; + int mCurrentSearchedMsg; KMSearchPattern* mSearchPattern; }; Index: kmfoldercachedimap.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdepim/kmail/kmfoldercachedimap.cpp,v retrieving revision 1.171 diff -u -p -r1.171 kmfoldercachedimap.cpp =2D-- kmfoldercachedimap.cpp 29 Mar 2005 22:24:27 -0000 1.171 +++ kmfoldercachedimap.cpp 14 Apr 2005 23:21:37 -0000 @@ -313,7 +313,7 @@ void KMFolderCachedImap::reloadUidMap() KMMsgBase *msg =3D getMsgBase( i ); if( !msg ) continue; ulong uid =3D msg->UID(); =2D kdDebug(5006) << "Inserting: " << i << " with uid: " << uid << endl; + //kdDebug(5006) << "Inserting: " << i << " with uid: " << uid << endl; uidMap.insert( uid, i ); } close(); Index: kmfoldermaildir.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdepim/kmail/kmfoldermaildir.cpp,v retrieving revision 1.101 diff -u -p -r1.101 kmfoldermaildir.cpp =2D-- kmfoldermaildir.cpp 31 Mar 2005 20:37:52 -0000 1.101 +++ kmfoldermaildir.cpp 14 Apr 2005 23:21:37 -0000 @@ -465,7 +465,16 @@ if( fileD0.open( IO_WriteOnly ) ) { mUnreadMsgs =3D 1; else ++mUnreadMsgs; =2D emit numUnreadMsgsChanged( folder() ); + if ( !mQuiet ) { + kdDebug( 5006 ) << "FolderStorage::msgStatusChanged" << endl; + emit numUnreadMsgsChanged( folder() ); + }else{ + if ( !mQuietTimer->isActive() ) { + kdDebug( 5006 )<< "QuietTimer started" << endl; + mQuietTimer->start( 3000 ); + } + mChanged =3D true; + } } ++mTotalMsgs; =20 Index: kmfoldertree.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdepim/kmail/kmfoldertree.cpp,v retrieving revision 1.355 diff -u -p -r1.355 kmfoldertree.cpp =2D-- kmfoldertree.cpp 6 Apr 2005 06:49:05 -0000 1.355 +++ kmfoldertree.cpp 14 Apr 2005 23:21:38 -0000 @@ -291,6 +291,8 @@ KMFolderTree::KMFolderTree( KMMainWidget mMainWidget =3D mainWidget; mReloading =3D false; =20 + mUpdateCountTimer=3D new QTimer( this ); + addAcceptableDropMimetype(MailListDrag::format(), false); =20 int namecol =3D addColumn( i18n("Folder"), 250 ); @@ -313,6 +315,9 @@ KMFolderTree::KMFolderTree( KMMainWidget // connects all needed signals to their slots void KMFolderTree::connectSignals() { + connect( mUpdateCountTimer, SIGNAL(timeout()), + this, SLOT(slotUpdateCountTimeout()) ); + connect(&mUpdateTimer, SIGNAL(timeout()), this, SLOT(delayedUpdate())); =20 @@ -534,7 +539,7 @@ void KMFolderTree::reload(bool openFolde fti,SLOT(slotNameChanged())); connect(fti->folder(),SIGNAL(nameChanged()), fti,SLOT(slotNameChanged())); =2D +/* if (fti->folder()->folderType() =3D=3D KMFolderTypeImap) { // imap-only KMFolderImap *imapFolder =3D @@ -543,23 +548,23 @@ void KMFolderTree::reload(bool openFolde this,SLOT(slotUpdateCounts(KMFolderImap*, bool))); connect( imapFolder, SIGNAL(folderComplete(KMFolderImap*, bool)), this,SLOT(slotUpdateCounts(KMFolderImap*, bool))); =2D } else { + } else*/ { // others-only, imap doesn't need this because of the folderComplete= =2Dsignal // we want to be noticed of changes to update the unread/total colum= ns disconnect(fti->folder(), SIGNAL(msgAdded(KMFolder*,Q_UINT32)), =2D this,SLOT(slotUpdateCounts(KMFolder*))); + this,SLOT(slotUpdateCountsDelayed(KMFolder*))); connect(fti->folder(), SIGNAL(msgAdded(KMFolder*,Q_UINT32)), =2D this,SLOT(slotUpdateCounts(KMFolder*))); + this,SLOT(slotUpdateCountsDelayed(KMFolder*))); } =20 disconnect(fti->folder(), SIGNAL(numUnreadMsgsChanged(KMFolder*)), =2D this,SLOT(slotUpdateCounts(KMFolder*))); + this,SLOT(slotUpdateCountsDelayed(KMFolder*))); connect(fti->folder(), SIGNAL(numUnreadMsgsChanged(KMFolder*)), =2D this,SLOT(slotUpdateCounts(KMFolder*))); + this,SLOT(slotUpdateCountsDelayed(KMFolder*))); disconnect(fti->folder(), SIGNAL(msgRemoved(KMFolder*)), =2D this,SLOT(slotUpdateCounts(KMFolder*))); + this,SLOT(slotUpdateCountsDelayed(KMFolder*))); connect(fti->folder(), SIGNAL(msgRemoved(KMFolder*)), =2D this,SLOT(slotUpdateCounts(KMFolder*))); + this,SLOT(slotUpdateCountsDelayed(KMFolder*))); =20 disconnect(fti->folder(), SIGNAL(shortcutChanged(KMFolder*)), mMainWidget, SLOT( slotShortcutChanged(KMFolder*))); @@ -1455,8 +1460,39 @@ void KMFolderTree::slotUpdateCounts(KMFo } =20 //------------------------------------------------------------------------= =2D---- +void KMFolderTree::slotUpdateCountsDelayed(KMFolder * folder) +{ +// kdDebug(5006) << "KMFolderTree::slotUpdateCountsDelayed()" << endl; + if ( !mFolderToUpdateCount.contains( folder->idString() ) ) + { +// kdDebug( 5006 )<< "adding " << folder->idString() << " to updateCoun= tList " << endl; + mFolderToUpdateCount.insert( folder->idString(),folder ); + } + if ( !mUpdateCountTimer->isActive() ) + mUpdateCountTimer->start( 500 ); +} + + +void KMFolderTree::slotUpdateCountTimeout() +{ + kdDebug(5006) << "KMFolderTree::slotUpdateCountTimeout()" << endl; + + + QMap::iterator it; + for ( it=3D mFolderToUpdateCount.begin(); + it!=3DmFolderToUpdateCount.end(); + ++it ) + { + slotUpdateCounts( it.data() ); + } + mFolderToUpdateCount.clear(); + mUpdateCountTimer->stop(); + +} + void KMFolderTree::slotUpdateCounts(KMFolder * folder) { + kdDebug(5006) << "KMFolderTree::slotUpdateCounts()" << endl; QListViewItem * current; if (folder) current =3D indexOfFolder(folder); Index: kmfoldertree.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /home/kde/kdepim/kmail/kmfoldertree.h,v retrieving revision 1.92 diff -u -p -r1.92 kmfoldertree.h =2D-- kmfoldertree.h 2 Feb 2005 21:25:24 -0000 1.92 +++ kmfoldertree.h 14 Apr 2005 23:21:39 -0000 @@ -268,6 +268,9 @@ protected slots: /** Update the total and unread columns (if available) */ void slotUpdateCounts(KMFolder * folder); void slotUpdateCounts(KMFolderImap * folder, bool success =3D true); + /** Update the total and unread columns but delayed */ + void slotUpdateCountsDelayed(KMFolder * folder); + void slotUpdateCountTimeout(); void slotUpdateOneCount(); =20 /** slots for the unread/total-popup */ @@ -340,6 +343,9 @@ private: bool mReloading; QMap mFolderToItem; =20 + QTimer *mUpdateCountTimer; + QMap mFolderToUpdateCount; + /** Map menu id into a folder */ KMMenuToFolder mMenuToFolder; }; --Boundary-01=_0/vXCYVOJOnNQBY-- --nextPart3013829.ar9hvgpEXe Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQBCXv/7MKsc+XeZcdwRAg3JAJ9N7H2dj2Qs6SIeojjKIOVW4RrGLQCfVn1K CJGgQYZvstqohI8lePcSLkw= =+DpU -----END PGP SIGNATURE----- --nextPart3013829.ar9hvgpEXe-- --===============1598086927== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ KMail developers mailing list KMail-devel@kde.org https://mail.kde.org/mailman/listinfo/kmail-devel --===============1598086927==--