emailuis/emailui/src/FreestyleEmailUiMailListModel.cpp
branchRCL_3
changeset 20 efd4f1afd43e
parent 10 f5907b1a1053
--- a/emailuis/emailui/src/FreestyleEmailUiMailListModel.cpp	Wed Jun 09 09:22:57 2010 +0300
+++ b/emailuis/emailui/src/FreestyleEmailUiMailListModel.cpp	Mon Jun 21 15:20:54 2010 +0300
@@ -250,20 +250,23 @@
     CFSEmailUiMailListModelItem* item = 
         static_cast< CFSEmailUiMailListModelItem* >( Item(aIndex) );
     
-    // Mail type items own the message. Delete the existing message first.
-    if ( item->ModelItemType() == ETypeMailItem )
+    if ( item ) // Safety
         {
-        delete &item->MessagePtr();
-        }
-    item->SetMessagePtr( aNewPtr );
-    
-    // If the item was the first child of a node, then also message pointer in the parent
-    // node needs to be updated
-    if ( aIndex > 0 &&
-         item->ModelItemType() == ETypeMailItem &&
-         iItems[aIndex-1]->ModelItemType() == ETypeSeparator )
-        {
-        iItems[aIndex-1]->SetMessagePtr( aNewPtr );
+        // Mail type items own the message. Delete the existing message first.
+        if ( item->ModelItemType() == ETypeMailItem )
+            {
+            delete &item->MessagePtr();
+            }
+        item->SetMessagePtr( aNewPtr );
+        
+        // If the item was the first child of a node, then also message pointer in the parent
+        // node needs to be updated
+        if ( aIndex > 0 &&
+             item->ModelItemType() == ETypeMailItem &&
+             iItems[aIndex-1]->ModelItemType() == ETypeSeparator )
+            {
+            iItems[aIndex-1]->SetMessagePtr( aNewPtr );
+            }
         }
     }