Index: imapaccountbase.cpp
===================================================================
--- imapaccountbase.cpp	(.../tags/kdepim/proko2_1_3/kdepim/kmail)	(revision 572909)
+++ imapaccountbase.cpp	(.../branches/kdepim/proko2/kdepim/kmail)	(revision 572909)
@@ -854,14 +854,16 @@
      ImapAccountBase::JobIterator it = findJob(job);
      if ( it == jobsEnd() ) return;
      int errorCode = job->error();
+     KMFolder * const parent = (*it).parent;
+     const QString path = (*it).path;
      if (errorCode && errorCode != KIO::ERR_CANNOT_OPEN_FOR_WRITING)
      {
        bool cont = handleJobError( job, i18n( "Error while uploading status of messages to server: " ) + '\n' );
-       emit imapStatusChanged( (*it).parent, (*it).path, cont );
+       emit imapStatusChanged( parent, path, cont );
      }
      else
      {
-       emit imapStatusChanged( (*it).parent, (*it).path, true );
+       emit imapStatusChanged( parent, path, true );
        removeJob(it);
      }
   }
Index: kmfoldercachedimap.cpp
===================================================================
--- kmfoldercachedimap.cpp	(.../tags/kdepim/proko2_1_3/kdepim/kmail)	(revision 572909)
+++ kmfoldercachedimap.cpp	(.../branches/kdepim/proko2/kdepim/kmail)	(revision 572909)
@@ -1245,6 +1245,10 @@
 
 void KMFolderCachedImap::slotImapStatusChanged(KMFolder* folder, const QString&, bool cont)
 {
+  if ( mSyncState == SYNC_STATE_INITIAL ){
+      kdDebug(5006) << "IMAP status changed but reset " << endl;
+      return; // we were reset
+  }
   if ( folder->storage() == this ) {
     --mStatusFlagsJobs;
     if ( mStatusFlagsJobs == 0 || !cont ) // done or aborting
@@ -1970,6 +1974,7 @@
 // called by KMAcctCachedImap::killAllJobs
 void KMFolderCachedImap::resetSyncState()
 {
+  if ( mSyncState == SYNC_STATE_INITIAL ) return;
   mSubfoldersForSync.clear();
   mSyncState = SYNC_STATE_INITIAL;
   close();
Index: networkaccount.h
===================================================================
--- networkaccount.h	(.../tags/kdepim/proko2_1_3/kdepim/kmail)	(revision 572909)
+++ networkaccount.h	(.../branches/kdepim/proko2/kdepim/kmail)	(revision 572909)
@@ -25,6 +25,8 @@
 #ifndef __KMAIL_NETWORKACCOUNT_H__
 #define __KMAIL_NETWORKACCOUNT_H__
 
+#include <qguardedptr.h>
+
 #include "kmaccount.h"
 
 #include "sieveconfig.h"
@@ -116,7 +118,7 @@
 
   protected:
     KMail::SieveConfig mSieveConfig;
-    KIO::Slave * mSlave;
+    QGuardedPtr<KIO::Slave> mSlave;
     QString mLogin, mPasswd, mAuth, mHost;
     unsigned short int mPort;
     bool mStorePasswd : 1;

