emailservices/psmruadapter/src/CPsMruAdapter.cpp
branchRCL_3
changeset 20 efd4f1afd43e
parent 18 6b8f3b30d0ec
child 22 d620048b4810
--- a/emailservices/psmruadapter/src/CPsMruAdapter.cpp	Wed Jun 09 09:22:57 2010 +0300
+++ b/emailservices/psmruadapter/src/CPsMruAdapter.cpp	Mon Jun 21 15:20:54 2010 +0300
@@ -286,15 +286,13 @@
 // code was simplified not to trace all mailboxes
 // function has trap in  Event() -case> TFSEventNewMailbox and in DeleayedMailboxCreationEventL()
 // should not leave when new mailbox only when new mail address
-    CFSMailBox *mailBox = iMailClient->GetMailBoxByUidL(aId);
-    if ( mailBox )
+    CFSMailBox *mailBox = iMailClient->GetMailBoxByUidLC(aId);
+    if( mailBox )
         {
-        CleanupStack::PushL( mailBox );
         AddMailboxObserverL( aId );
         
         // Get MRU list for this mailbox
         MDesCArray* mruList = mailBox->ListMrusL();
-        CleanupStack::PopAndDestroy( mailBox );
         
         // update the caching status as InProgress
         iDataStoreObserver->UpdateCachingStatus( aDataStoreURI,
@@ -319,6 +317,7 @@
             }
         result = ETrue;
         }   // if (mailBox)
+    CleanupStack::PopAndDestroy( mailBox );
     return result;
     }
 
@@ -452,12 +451,18 @@
                 {
                 mailboxPtr = NULL;
                 }
-            if (NULL == mailboxPtr) // mailbox still does not exist 
+            if( mailboxPtr ) 
                 {
+                delete mailboxPtr;
+                mailboxPtr = NULL;
+                }
+            else
+                {
+                // mailbox still does not exist
                 DeleayMailboxCreationEventL( aMailbox ); // start timer to postpone creation	
                 break;
                 }
-            mailboxPtr = NULL;
+            
             HBufC* identifier = HBufC::NewLC( KMaximumMailboxUriLength ); // new string ident
             if ( GetUriFromMailboxIdentifier( aMailbox, *identifier ) )
                 {
@@ -572,6 +577,9 @@
             }
         if ( mailboxPtr ) 
             {
+            delete mailboxPtr;
+            mailboxPtr = NULL;
+            
             HBufC* identifier = HBufC::NewLC( KMaximumMailboxUriLength ); // new string ident
             if ( GetUriFromMailboxIdentifier( iDelayedCreatedMailboxes[i], *identifier ) )
                 {