idlefw/plugins/profileplugin/src/caiprofileengine.cpp
branchRCL_3
changeset 14 15e4dd19031c
parent 11 bd874ee5e5e2
child 23 ace62b58f4b2
--- a/idlefw/plugins/profileplugin/src/caiprofileengine.cpp	Mon Mar 15 12:41:53 2010 +0200
+++ b/idlefw/plugins/profileplugin/src/caiprofileengine.cpp	Wed Mar 31 22:04:35 2010 +0300
@@ -215,26 +215,35 @@
         TInt generalProfileIndex( 
             profileNamesArray->FindById( KGeneralProfileId ) );
         
-		swapProfileName = 
-            profileNamesArray->MdcaPoint( generalProfileIndex ).AllocLC() ;		        
+        if( generalProfileIndex > KErrNotFound )
+            {
+            swapProfileName = 
+                profileNamesArray->MdcaPoint( generalProfileIndex ).AllocLC() ; 
+            }
     	}
     else
         {
         TInt silentProfileIndex( 
             profileNamesArray->FindById( KSilentProfileId ) );	
 		
-        swapProfileName = 
-            profileNamesArray->MdcaPoint( silentProfileIndex ).AllocLC() ;                
+        if( silentProfileIndex > KErrNotFound )
+            {
+            swapProfileName = 
+                profileNamesArray->MdcaPoint( silentProfileIndex ).AllocLC() ;  
+            }
         }
     
-    TPtrC swapProfileNamePtr( *swapProfileName );
-	   
-	HBufC* activateProfileString( StringLoader::LoadLC( 
-        R_AI_PERS_PROF_TOGGLE, swapProfileNamePtr ) );    	
-    
-    SetSwapProfileNameL( *activateProfileString );
+    if( swapProfileName )
+        { 
+        HBufC* activateProfileString( StringLoader::LoadLC( 
+            R_AI_PERS_PROF_TOGGLE, swapProfileName->Des() ) );      
+        
+        SetSwapProfileNameL( *activateProfileString );
+        
+        CleanupStack::PopAndDestroy( 2 ); // swapProfileName, activateProfileString
+        }
 
-    CleanupStack::PopAndDestroy( 5 ); //profile, profileName, // profileNamesArray, swapProfileName, activateProfileString           
+    CleanupStack::PopAndDestroy( 3 ); //profile, profileName, profileNamesArray,           
 	}
 
 // ----------------------------------------------------------------------------