phonebookengines/VirtualPhonebook/VPbkCntModel/src/CViewBase.cpp
branchRCL_3
changeset 57 2666d9724c76
parent 23 5586b4d2ec3e
child 64 c1e8ba0c2b16
--- a/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CViewBase.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookengines/VirtualPhonebook/VPbkCntModel/src/CViewBase.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -246,7 +246,7 @@
     {
     TInt result = KErrNotFound;
 
-    if (&aContactLink.ContactStore() == &ContactStore())
+    if (&aContactLink.ContactStore() == &ContactStore() && iView )
         {
         const CContactLink& link = static_cast<const CContactLink&>(aContactLink);
         result = iView->FindL(link.ContactId());
@@ -773,8 +773,16 @@
         const CVPbkContactViewDefinition& aViewDefinition,
         const MVPbkFieldTypeList& aSortOrder )
     {
-    iCurrentContact = CViewContact::NewL( *this, aSortOrder );
-
+    
+    CViewContact* vievContact = CViewContact::NewL( *this, aSortOrder );
+    if ( iCurrentContact )
+        {
+        delete iCurrentContact;
+        iCurrentContact = NULL;
+        }
+    iCurrentContact = vievContact;
+    vievContact = NULL;
+    
     RContactViewSortOrder viewSortOrder = CreateSortOrderL( aSortOrder );
     CleanupClosePushL( viewSortOrder );
 
@@ -795,8 +803,15 @@
 
     CleanupStack::PopAndDestroy(); // viewSortOrder
 
-    iEventLink = CContactLink::NewLC( iParentStore, KNullContactId );
-    CleanupStack::Pop( iEventLink );
+    CContactLink* contactLink= CContactLink::NewLC( iParentStore, KNullContactId );
+    CleanupStack::Pop( contactLink );
+    if ( iEventLink )
+        {
+        delete iEventLink;
+        iEventLink = NULL;
+        }
+    iEventLink = contactLink;
+    contactLink = NULL;
     }
 
 // --------------------------------------------------------------------------