phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherlpadmodel.cpp
--- a/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherlpadmodel.cpp Tue Sep 14 20:54:53 2010 +0300
+++ b/phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlauncherlpadmodel.cpp Wed Sep 15 11:56:55 2010 +0300
@@ -971,11 +971,21 @@
presData.PreparePresenceDataL( iPresenceIconSize );
TUint32 serviceType = presData.ServiceType();
+ // The ownerships of mask and bitmap are transferred to this object.
+ CFbsBitmap* mask = presData.Mask();
+ CFbsBitmap* bitmap = presData.Bitmap();
+ TBool isValidBitmap = !( bitmap && ( NULL == bitmap->Handle() ) );
+
+ // If any one of below condition is satisfied, the bitmap and mask are invalid.
+ // Delete them since the ownerships of them are transferred to this object.
+ if ( !isValidBitmap || serviceType != CCmsContactFieldItem::ECmsPresenceChatNotification )
+ {
+ delete mask;
+ delete bitmap;
+ }
+
if ( serviceType == CCmsContactFieldItem::ECmsPresenceChatNotification )
- {
- CFbsBitmap* mask = presData.Mask();
- CFbsBitmap* bitmap = presData.Bitmap();
-
+ {
// Find the index for chat item
TInt index = KErrNotFound;
const TInt dataCount = iButtonDataArray.Count();
@@ -994,41 +1004,35 @@
TBool hasPresenceIcon = iButtonDataArray[ index ].iFlags &
TCommLauncherButtonData::EHasPresenceIcon;
- if ( bitmap && ( NULL == bitmap->Handle() ) )
+ if ( hasPresenceIcon )
{
- if ( hasPresenceIcon )
- {
- // Delete presence icon from icon array
- iButtonDataArray[ index ].iFlags &= ~(TCommLauncherButtonData::EHasPresenceIcon);
- iButtonIconArray->Delete( EPresenceIconIndex );
- }
+ if ( isValidBitmap )
+ {
+ // Update presence icon
+ iButtonIconArray->At( EPresenceIconIndex )->SetBitmap(bitmap);
+ iButtonIconArray->At( EPresenceIconIndex )->SetMask(mask);
+ }
+ else
+ {
+ // Delete presence icon from icon array
+ iButtonDataArray[ index ].iFlags &= ~(TCommLauncherButtonData::EHasPresenceIcon);
+ CGulIcon* icon = iButtonIconArray->At( EPresenceIconIndex );
+ delete icon;
+ iButtonIconArray->Delete( EPresenceIconIndex );
+ }
}
- else if ( bitmap )
- {
- if ( hasPresenceIcon )
- {
- // Update presence icon
- iButtonIconArray->At( EPresenceIconIndex )->SetBitmap(bitmap);
- iButtonIconArray->At( EPresenceIconIndex )->SetMask(mask);
- }
- else
- {
- // Append presence icon to icon array
- CGulIcon* icon = CGulIcon::NewLC();
- icon->SetBitmap( bitmap );
- icon->SetMask( mask );
- iButtonIconArray->AppendL( icon );
- iButtonDataArray[ index ].iFlags |= TCommLauncherButtonData::EHasPresenceIcon;
- CleanupStack::Pop(); // icon
- }
- }
+ else if ( isValidBitmap )
+ {
+ // Append presence icon to icon array
+ CGulIcon* icon = CGulIcon::NewLC();
+ icon->SetBitmap( bitmap );
+ icon->SetMask( mask );
+ iButtonIconArray->AppendL( icon );
+ iButtonDataArray[ index ].iFlags |= TCommLauncherButtonData::EHasPresenceIcon;
+ CleanupStack::Pop(); // icon
+ }
}
}
- else
- {
- delete presData.Bitmap();
- delete presData.Mask();
- }
}
}