Bug 735940 - if filter target folder is moved, all subsequent filters got their targets set to this folder. r+a=Standard8
authoraceman <acelists@atlas.sk>
Mon, 26 Mar 2012 10:45:42 +0100
changeset 10683 816333b3a46070e8ac8288ec71c9066f80fa7e54
parent 10682 1f375f15344be8a6ae35823c1e8ddd336faa0935
child 10684 ad8f79a72aa22df2d5caefcd8bb28a787b8f097b
push idunknown
push userunknown
push dateunknown
bugs735940
Bug 735940 - if filter target folder is moved, all subsequent filters got their targets set to this folder. r+a=Standard8
mailnews/base/search/src/nsMsgFilterList.cpp
--- a/mailnews/base/search/src/nsMsgFilterList.cpp
+++ b/mailnews/base/search/src/nsMsgFilterList.cpp
@@ -1099,62 +1099,66 @@ nsMsgFilterList::GetVersion(PRInt16 *aRe
 }
 
 NS_IMETHODIMP nsMsgFilterList::MatchOrChangeFilterTarget(const nsACString &oldFolderUri, const nsACString &newFolderUri, bool caseInsensitive, bool *found)
 {
   NS_ENSURE_ARG_POINTER(found);
 
   PRUint32 numFilters;
   nsresult rv = m_filters->Count(&numFilters);
-  NS_ENSURE_SUCCESS(rv,rv);
-  nsCOMPtr <nsIMsgFilter> filter;
+  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIMsgFilter> filter;
   nsCString folderUri;
   *found = false;
   for (PRUint32 index = 0; index < numFilters; index++)
   {
     filter = do_QueryElementAt(m_filters, index, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsCOMPtr<nsISupportsArray> filterActionList;
     rv = filter->GetActionList(getter_AddRefs(filterActionList));
+    NS_ENSURE_SUCCESS(rv, rv);
     PRUint32 numActions;
     filterActionList->Count(&numActions);
 
-    for (PRUint32 actionIndex =0; actionIndex < numActions; actionIndex++)
+    for (PRUint32 actionIndex = 0; actionIndex < numActions; actionIndex++)
     {
       nsCOMPtr<nsIMsgRuleAction> filterAction =
           do_QueryElementAt(filterActionList, actionIndex);
       nsMsgRuleActionType actionType;
       if (filterAction)
         filterAction->GetType(&actionType);
       else
         continue;
 
       if (actionType == nsMsgFilterAction::MoveToFolder ||
           actionType == nsMsgFilterAction::CopyToFolder)
       {
         rv = filterAction->GetTargetFolderUri(folderUri);
         if (NS_SUCCEEDED(rv) && !folderUri.IsEmpty())
         {
+          bool matchFound = false;
           if (caseInsensitive)
           {
             if (folderUri.Equals(oldFolderUri, nsCaseInsensitiveCStringComparator())) //local
-              *found = true;
+              matchFound = true;
           }
           else
           {
             if (folderUri.Equals(oldFolderUri))  //imap
-              *found = true;
+              matchFound = true;
           }
-          if (*found)
-          { //if we just want to match the uri's, newFolderUri will be null
-            if (!newFolderUri.IsEmpty()) 
+          if (matchFound)
+          {
+            *found = true;
+            //if we just want to match the uri's, newFolderUri will be null
+            if (!newFolderUri.IsEmpty())
             {
               rv = filterAction->SetTargetFolderUri(newFolderUri);
-              NS_ENSURE_SUCCESS(rv,rv);
+              NS_ENSURE_SUCCESS(rv, rv);
             }
           }
         }
         break;  //we allow only one move action per filter
       }
     }
   }
   return rv;