diff -r 6b8f3b30d0ec -r efd4f1afd43e emailuis/emailui/src/FreestyleEmailUiMailListModel.cpp --- 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 ); + } } }