Bug 471492 - keep local copy of database to stop crashes, r=bienvenu,a=Standard8 GECKO1701_2013010313_RELBRANCH
authorKent James <kent@caspia.com>
Mon, 01 Oct 2012 09:33:09 -0700
branchGECKO1701_2013010313_RELBRANCH
changeset 30924 15c2277fdfa9c1fa7a31e08b610463c5ab7961af
parent 30923 f97075851d577c82a9145180d3933aebf8d9414f
child 30925 49618fc13d0e99a3e27bf1d3cf78e02d8bc3bc19
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu, Standard8
bugs471492
Bug 471492 - keep local copy of database to stop crashes, r=bienvenu,a=Standard8
mailnews/imap/src/nsImapMailFolder.cpp
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -7101,23 +7101,24 @@ nsresult nsImapMailFolder::CopyMessagesO
   if (sourceMailDB)
   {
     // save the future ops in the source DB, if this is not a imap->local copy/move
     nsCOMPtr <nsITransactionManager> txnMgr;
     if (msgWindow)
       msgWindow->GetTransactionManager(getter_AddRefs(txnMgr));
     if (txnMgr)
       txnMgr->BeginBatch();
-    GetDatabase();
-    if (mDatabase)
+    nsCOMPtr<nsIMsgDatabase> database;
+    GetMsgDatabase(getter_AddRefs(database));
+    if (database)
     {
       // get the highest key in the dest db, so we can make up our fake keys
       nsMsgKey fakeBase = 1;
       nsCOMPtr <nsIDBFolderInfo> folderInfo;
-      rv = mDatabase->GetDBFolderInfo(getter_AddRefs(folderInfo));
+      rv = database->GetDBFolderInfo(getter_AddRefs(folderInfo));
       NS_ENSURE_SUCCESS(rv, rv);
       nsMsgKey highWaterMark = nsMsgKey_None;
       folderInfo->GetHighWater(&highWaterMark);
       fakeBase += highWaterMark;
       nsMsgKey fakeTop = fakeBase + srcCount;
       // Check that we have enough room for the fake headers. If fakeTop
       // is <= highWaterMark, we've overflowed.
       if (fakeTop <= highWaterMark || fakeTop == nsMsgKey_None)
@@ -7230,17 +7231,17 @@ nsresult nsImapMailFolder::CopyMessagesO
         rv = sourceMailDB->GetMsgHdrForKey(originalKey, getter_AddRefs(mailHdr));
         if (NS_SUCCEEDED(rv) && mailHdr)
         {
           bool successfulCopy = false;
           nsMsgKey srcDBhighWaterMark;
           srcDbFolderInfo->GetHighWater(&srcDBhighWaterMark);
 
           nsCOMPtr <nsIMsgDBHdr> newMailHdr;
-          rv = mDatabase->CopyHdrFromExistingHdr(fakeBase + sourceKeyIndex, mailHdr,
+          rv = database->CopyHdrFromExistingHdr(fakeBase + sourceKeyIndex, mailHdr,
             true, getter_AddRefs(newMailHdr));
           if (!newMailHdr || NS_FAILED(rv))
           {
             NS_ASSERTION(false, "failed to copy hdr");
             stopit = rv;
           }
 
           if (NS_SUCCEEDED(stopit))
@@ -7260,26 +7261,26 @@ nsresult nsImapMailFolder::CopyMessagesO
               CopyOfflineMsgBody(srcFolder, newMailHdr, mailHdr, inputStream,
                                  outputStream);
               nsCOMPtr<nsIMsgPluggableStore> offlineStore;
               (void) GetMsgStore(getter_AddRefs(offlineStore));
               if (offlineStore)
                 offlineStore->FinishNewMessage(outputStream, newMailHdr);
             }
             else
-              mDatabase->MarkOffline(fakeBase + sourceKeyIndex, false, nullptr);
+              database->MarkOffline(fakeBase + sourceKeyIndex, false, nullptr);
 
             nsCOMPtr <nsIMsgOfflineImapOperation> destOp;
-            mDatabase->GetOfflineOpForKey(fakeBase + sourceKeyIndex, true, getter_AddRefs(destOp));
+            database->GetOfflineOpForKey(fakeBase + sourceKeyIndex, true, getter_AddRefs(destOp));
             if (destOp)
             {
               // check if this is a move back to the original mailbox, in which case
               // we just delete the offline operation.
               if (messageReturningHome)
-                mDatabase->RemoveOfflineOp(destOp);
+                database->RemoveOfflineOp(destOp);
               else
               {
                 SetFlag(nsMsgFolderFlags::OfflineEvents);
                 destOp->SetSourceFolderURI(originalSrcFolderURI.get());
                 destOp->SetSrcMessageKey(originalKey);
                 addedKeys.AppendElement(fakeBase + sourceKeyIndex);
                 addedHdrs.AppendObject(newMailHdr);
               }
@@ -7349,17 +7350,17 @@ nsresult nsImapMailFolder::CopyMessagesO
         if (txnMgr)
            txnMgr->DoTransaction(undoMsgTxn);
       }
       if (outputStream)
         outputStream->Close();
 
       if (isMove)
         sourceMailDB->Commit(nsMsgDBCommitType::kLargeCommit);
-      mDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
+      database->Commit(nsMsgDBCommitType::kLargeCommit);
       SummaryChanged();
       srcFolder->SummaryChanged();
     }
     if (txnMgr)
       txnMgr->EndBatch();
   }
 
   // Do this before delete, as it destroys the messages