uifw/AvKon/src/AknAdaptiveSearchGrid.cpp
branchRCL_3
changeset 18 fcdfafb36fe7
parent 12 941195f2d488
child 19 aecbbf00d063
--- a/uifw/AvKon/src/AknAdaptiveSearchGrid.cpp	Thu Jul 15 18:56:19 2010 +0300
+++ b/uifw/AvKon/src/AknAdaptiveSearchGrid.cpp	Thu Aug 19 10:11:06 2010 +0300
@@ -1241,7 +1241,12 @@
             }
         }
     _AKNTRACE_FUNC_EXIT;
-    }       
+    }     
+
+static CAknButton* GetButtonHelper( RPointerArray<CAknButton> &aButtonArray, TInt aIndex )
+    {
+    return ( aIndex < aButtonArray.Count() && aIndex >= 0 ) ? aButtonArray[aIndex] : NULL;
+    }
 
 // -----------------------------------------------------------------------------
 // CAknAdaptiveSearchGrid::UpdateVisibleButtonsL()
@@ -1274,8 +1279,11 @@
         CAknButton* tmpButton = NULL;    
         for( TInt i = 0; i < iButtonArray.Count(); i++ )
             {
-            tmpButton = static_cast<CAknButton*>( iButtonArray[i] );            
-            tmpButton->MakeVisible( EFalse );
+            tmpButton = GetButtonHelper( iButtonArray, i );
+            if ( NULL != tmpButton )
+                {
+                tmpButton->MakeVisible( EFalse );
+                }
             }
                 
         TInt tempTotalGridButtons = iTotalGridButtons - KCloseAndClearButtonCount;               
@@ -1283,7 +1291,12 @@
             {       
             for ( TInt i = 0; i < tempTotalGridButtons; i++ )
                 {
-                button = static_cast<CAknButton*>( iButtonArray[tempTotalGridButtons-i-1] );
+                button = GetButtonHelper( iButtonArray, tempTotalGridButtons-i-1 );
+                if ( NULL == button )
+                    {
+                    continue;
+                    }
+                
                 TInt charPosition = numOfChars-i-1-shift_Ind;
                 if ( charPosition >= 0 ) 
                     {
@@ -1299,7 +1312,7 @@
                         button->SetIconSize( iButtonIconSize );                                      
                         }
                     else
-                        {
+                        { 
                         if( bState->Icon() )
                             {
                             bState->SetIcon( NULL );          
@@ -1356,8 +1369,13 @@
                 TInt offset = tempTotalGridButtons - charsOnLastPage;   
                 
                 for ( TInt i = tempTotalGridButtons-1 ; i >= 0 ; --i )
-                    {
-                    button = static_cast<CAknButton*>(iButtonArray[i+shift_Ind]);
+                    {                  
+                    button = GetButtonHelper( iButtonArray, i+shift_Ind );
+                    if ( NULL == button )
+                        {
+                        continue;
+                        }
+                
                     if( i < offset )
                         {
                         button->MakeVisible( EFalse );                  
@@ -1414,8 +1432,13 @@
                 for ( TInt i = 0; i < numOfChars; i++ )
                     {
                     if ( ( i >= start) && (i < end) )
-                        {   
-                        button = static_cast<CAknButton*>(iButtonArray[i-start-shift_Ind]);
+                        {                      
+                        button = GetButtonHelper( iButtonArray, i-start-shift_Ind );
+                        if ( NULL == button )
+                            {
+                            continue;
+                            }
+                    
                         bState = button->State();               
                         if( ptr.Mid(i, 1) == KSpaceCharacter )
                             {  
@@ -1468,8 +1491,12 @@
                         }
                     for ( TInt i = tempTotalGridButtons; i < tempTotalGridButtons+iNumOfCols; i++ )
                         {
-                        button = static_cast<CAknButton*>(iButtonArray[i]);
-                        button->MakeVisible( EFalse );  
+                        button = GetButtonHelper( iButtonArray, i );
+                        if ( NULL != button )
+                            {
+                            button->MakeVisible( EFalse );  
+                            }
+                        
                         }           
                 }               
             }