phonebookui/Phonebook2/UIControls/src/CPbk2ContactViewListBox.cpp
branchRCL_3
changeset 57 2666d9724c76
parent 32 2828b4d142c0
child 58 d4f567ce2e7c
--- a/phonebookui/Phonebook2/UIControls/src/CPbk2ContactViewListBox.cpp	Mon Jun 21 15:24:27 2010 +0300
+++ b/phonebookui/Phonebook2/UIControls/src/CPbk2ContactViewListBox.cpp	Thu Jul 15 18:22:55 2010 +0300
@@ -58,6 +58,8 @@
 
 // LOCAL FUNCTIONS
 
+_LIT( KTabChar, "\t" );
+
 /**
  * Returns icon array from given list box.
  *
@@ -702,14 +704,20 @@
         textLayout.LayoutText(layout.Rect(), AknLayoutScalable_Apps::popup_navstr_preview_pane_t1(0).LayoutLine());
 
         TPtrC desc(Model()->ItemTextArray()->MdcaPoint(View()->TopItemIndex()));
+		
+        //Add "if-clause" to avaid the error that argument of Mid() out of range.
+        TInt index = desc.Find( KTabChar );
+        if ( index != KErrNotFound && index < desc.Length()-1 )
+            {
+            HBufC* buf = desc.Mid( index + 1, 1 ).AllocL();           
 
-        HBufC* buf = desc.Mid(desc.Find(_L("\t")) + 1, 1).AllocL();
-        TPtr textPtr = buf->Des();
-        textPtr.UpperCase();
-        
-        textLayout.DrawText(*gc, textPtr, ETrue, normal );
-        
-        delete buf;
+            TPtr textPtr = buf->Des();
+            textPtr.UpperCase();
+
+            textLayout.DrawText( *gc, textPtr, ETrue, normal );
+
+            delete buf;
+            }
         }
     }
 // End of File