Index: kmail/folderjob.h =================================================================== --- kmail/folderjob.h (revision 578973) +++ kmail/folderjob.h (working copy) @@ -36,6 +36,7 @@ #include #include #include +#include class KMFolder; @@ -159,6 +160,9 @@ signals: */ void progress( unsigned long bytesDownloaded, unsigned long bytesTotal ); +private slots: + void slotMessageDeleted(QObject *); + private: void init(); @@ -169,6 +173,7 @@ protected: */ virtual void execute()=0; + QMap mMsgObjectMap; QPtrList mMsgList; JobType mType; QString mSets; Index: kmail/kmmessage.h =================================================================== --- kmail/kmmessage.h (revision 578973) +++ kmail/kmmessage.h (working copy) @@ -10,6 +10,7 @@ // for large file support #include #include +#include #include #include "kmmsgbase.h" @@ -47,6 +48,7 @@ namespace KMime { namespace KMail { class HeaderStrategy; + class FolderJob; } class DwBodyPart; @@ -67,6 +69,7 @@ namespace KMail { class KMMessage: public KMMsgBase, public KMail::ISubject { friend class ::KMForwardDigestCommand; // needed for MIME Digest forward + friend class KMail::FolderJob; public: // promote some of KMMsgBase's methods to public: @@ -868,6 +871,7 @@ private: KMMsgMDNSentState mMDNSentState; KMMessage* mUnencryptedMsg; DwBodyPart* mLastUpdated; + QObject mQObject; }; Index: kmail/folderjob.cpp =================================================================== --- kmail/folderjob.cpp (revision 578973) +++ kmail/folderjob.cpp (working copy) @@ -50,6 +50,8 @@ FolderJob::FolderJob( KMMessage *msg, Jo { if ( msg ) { mMsgList.append(msg); + mMsgObjectMap[&msg->mQObject] = msg; + connect(&msg->mQObject, SIGNAL(destroyed(QObject *)), this, SLOT(slotMessageDeleted(QObject *))); mSets = msg->headerField("X-UID"); } init(); @@ -123,6 +125,14 @@ FolderJob::msgList() const return mMsgList; } +void +FolderJob::slotMessageDeleted(QObject *obj) +{ + KMMessage *msg = mMsgObjectMap[obj]; + mMsgObjectMap.remove(obj); + mMsgList.removeRef(msg); +} + } #include "folderjob.moc"