Bug 209189 - Clear undo stack after permanent deletion. r=rkent, a=rkent
authorJorg K <mozilla@jorgk.com>
Sun, 12 Jul 2015 01:28:00 +0200
changeset 22892 661436d7a39d4e557cf611c35eae4a7e59ddd0cb
parent 22891 b1afb50fb6dd8a1eaad071c5a3135f034ea5a027
child 22893 1d6740a71280b3e045fa5d42ecc6b1982b050083
push id1467
push userkent@caspia.com
push dateTue, 15 Sep 2015 01:43:32 +0000
treeherdercomm-beta@3db4218c150a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrkent, rkent
bugs209189
Bug 209189 - Clear undo stack after permanent deletion. r=rkent, a=rkent
mailnews/local/src/nsLocalMailFolder.cpp
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -1217,18 +1217,18 @@ nsMsgLocalMailFolder::DeleteMessages(nsI
         rv = GetMsgStore(getter_AddRefs(msgStore));
         if (NS_SUCCEEDED(rv))
         {
           rv = msgStore->DeleteMessages(messages);
           GetDatabase();
           nsCOMPtr<nsIMsgDBHdr> msgDBHdr;
           if (mDatabase)
           {
-        for (uint32_t i = 0; i < messageCount; ++i)
-        {
+            for (uint32_t i = 0; i < messageCount; ++i)
+            {
               msgDBHdr = do_QueryElementAt(messages, i, &rv);
               rv = mDatabase->DeleteHeader(msgDBHdr, nullptr, false, true);
             }
           }
         }
       }
       else if (rv == NS_MSG_FOLDER_BUSY)
         ThrowAlertMsg("deletingMsgsFailed", msgWindow);
@@ -1238,16 +1238,25 @@ nsMsgLocalMailFolder::DeleteMessages(nsI
       // we've been caching, mark the db as valid, and commit it.
       EnableNotifications(allMessageCountNotifications, true, true /*dbBatching*/);
       if (!isMove)
         NotifyFolderEvent(NS_SUCCEEDED(rv) ? mDeleteOrMoveMsgCompletedAtom : mDeleteOrMoveMsgFailedAtom);
       if (msgWindow && !isMove)
         AutoCompact(msgWindow);
     }
   }
+
+  if (msgWindow && !isMove && (deleteStorage || isTrashFolder)) {
+    // Clear undo and redo stack.
+    nsCOMPtr<nsITransactionManager> txnMgr;
+    msgWindow->GetTransactionManager(getter_AddRefs(txnMgr));
+    if (txnMgr) {
+      txnMgr->Clear();
+    }
+  }
   return rv;
 }
 
 NS_IMETHODIMP
 nsMsgLocalMailFolder::AddMessageDispositionState(nsIMsgDBHdr *aMessage, nsMsgDispositionState aDispositionFlag)
 {
   nsMsgMessageFlagType msgFlag = 0;
   switch (aDispositionFlag) {