forward port of enterprise commit 703867: convert KMHeaders::applyFiltersOnMsg to using serial numbers instead of message pointers [in the case not using action scheduler]. Speculative fix to Intevation issue #1815 (Filtering 1450 mails crashes kontact).

svn path=/trunk/KDE/kdepim/; revision=703875
wilder-work
Andreas Hartmetz 19 years ago
parent 204648de96
commit 15091e94ce
  1. 55
      kmheaders.cpp
  2. 14
      kmmsgdict.cpp
  3. 5
      kmmsgdict.h

@ -1412,48 +1412,59 @@ void KMHeaders::applyFiltersOnMsg()
int contentX, contentY;
HeaderItem *nextItem = prepareMove( &contentX, &contentY );
KMMessageList* msgList = selectedMsgs();
if (msgList->isEmpty())
//prevent issues with stale message pointers by using serial numbers instead
QList<unsigned long> serNums = KMMsgDict::serNumList( *selectedMsgs() );
if ( serNums.isEmpty() )
return;
finalizeMove( nextItem, contentX, contentY );
finalizeMove( nextItem, contentX, contentY );
CREATE_TIMER(filter);
START_TIMER(filter);
KCursorSaver busy( KBusyPtr::busy() );
int msgCount = 0;
int msgCountToFilter = msgList->count();
int msgCountToFilter = serNums.count();
ProgressItem* progressItem =
ProgressManager::createProgressItem (
"filter"+ProgressManager::getUniqueID(),
i18n( "Filtering messages" ) );
progressItem->setTotalItems( msgCountToFilter );
QList<KMMsgBase*>::const_iterator it;
for ( it = msgList->begin(); it != msgList->end(); it++ ) {
KMMsgBase* msgBase = (*it);
int diff = msgCountToFilter - ++msgCount;
if ( diff < 10 || !( msgCount % 10 ) || msgCount <= 10 ) {
for ( QList<unsigned long>::ConstIterator it = serNums.constBegin();
it != serNums.constEnd(); ++it ) {
msgCount++;
if ( msgCountToFilter - msgCount < 10 || !( msgCount % 10 ) || msgCount <= 10 ) {
progressItem->updateProgress();
QString statusMsg = i18n( "Filtering message %1 of %2",
msgCount, msgCountToFilter );
KPIM::BroadcastStatus::instance()->setStatusMsg( statusMsg );
qApp->processEvents( QEventLoop::ExcludeUserInputEvents, 50 );
}
int idx = msgBase->parent()->find(msgBase);
assert(idx != -1);
KMMessage * msg = msgBase->parent()->getMsg(idx);
if (msg->transferInProgress()) continue;
msg->setTransferInProgress(true);
if ( !msg->isComplete() )
{
FolderJob *job = mFolder->createJob(msg);
connect(job, SIGNAL(messageRetrieved(KMMessage*)),
SLOT(slotFilterMsg(KMMessage*)));
job->start();
KMFolder *folder = 0;
int idx;
KMMsgDict::instance()->getLocation( *it, &folder, &idx );
KMMessage *msg = 0;
if (folder)
msg = folder->getMsg(idx);
if (msg) {
if (msg->transferInProgress())
continue;
msg->setTransferInProgress(true);
if ( !msg->isComplete() ) {
FolderJob *job = mFolder->createJob(msg);
connect(job, SIGNAL(messageRetrieved(KMMessage*)),
this, SLOT(slotFilterMsg(KMMessage*)));
job->start();
} else {
if (slotFilterMsg(msg) == 2)
break;
}
} else {
if (slotFilterMsg(msg) == 2) break;
kDebug (5006) << "####### KMHeaders::applyFiltersOnMsg -"
" A message went missing during filtering " << endl;
}
progressItem->incCompletedItems();
progressItem->incCompletedItems();
}
progressItem->setComplete();
progressItem = 0;

@ -353,6 +353,20 @@ unsigned long KMMsgDict::getMsgSerNum(KMFolder *folder, int index) const
//-----------------------------------------------------------------------------
//static
QList<unsigned long> KMMsgDict::serNumList(QList<KMMsgBase *> msgList)
{
QList<unsigned long> ret;
for ( unsigned int i = 0; i < msgList.count(); i++ ) {
unsigned long serNum = msgList.at(i)->getMsgSerNum();
assert( serNum );
ret.append( serNum );
}
return ret;
}
//-----------------------------------------------------------------------------
QString KMMsgDict::getFolderIdsLocation( const FolderStorage &storage )
{
return storage.indexLocation() + ".ids";

@ -20,6 +20,8 @@
#ifndef __KMMSGDICT
#define __KMMSGDICT
#include <QList>
class KMFolder;
class KMMsgBase;
class KMMessage;
@ -67,6 +69,9 @@ class KMMsgDict
* @return the message serial number or zero is no such message can be found */
unsigned long getMsgSerNum( KMFolder *folder, int index ) const;
/** Convert a list of KMMsgBase pointers to a list of serial numbers */
static QList<unsigned long> serNumList(QList<KMMsgBase *> msgList);
private:
/* FIXME It would be better to do without these, they are the classes
* involved in filling and maintaining the dict. The MsgList needs access

Loading…
Cancel
Save