idlehomescreen/xmluirendering/renderingplugins/xntextfactory/src/xntextadapter.cpp
branchRCL_3
changeset 11 ff572dfe6d86
parent 0 f72a12da539e
--- a/idlehomescreen/xmluirendering/renderingplugins/xntextfactory/src/xntextadapter.cpp	Fri Feb 19 22:42:37 2010 +0200
+++ b/idlehomescreen/xmluirendering/renderingplugins/xntextfactory/src/xntextadapter.cpp	Fri Mar 12 15:41:49 2010 +0200
@@ -141,33 +141,45 @@
                 
                 TInt lineCount( array->Count() );
                 
-                buffer = HBufC::NewLC( temp->Length() + ( lineCount - 1 ) );
-                
-                TPtr ptr( buffer->Des() );
-                                                
-                for( TInt i = 0; i < lineCount; i++ )
+                TInt bufLen = temp->Length() + ( lineCount - 1 );
+                if ( bufLen > 0 )
                     {
-                    TPtrC line( array->At( i ) );
-                    
-                    ptr.Append( line );
+                    buffer = HBufC::NewLC( bufLen );
                     
-                    if( i + 1 < lineCount )
+                    TPtr ptr( buffer->Des() );
+                                                    
+                    for( TInt i = 0; i < lineCount; i++ )
                         {
-                        ptr.Append( '\n' );
-                        }                    
+                        TPtrC line( array->At( i ) );
+                        
+                        ptr.Append( line );
+                        
+                        if( i + 1 < lineCount )
+                            {
+                            ptr.Append( '\n' );
+                            }                    
+                        }
+                        
+                    CleanupStack::Pop();
+                    CleanupStack::PopAndDestroy( temp );
+                    CleanupStack::PushL( buffer );
                     }
-                    
-                CleanupStack::Pop();
-                CleanupStack::PopAndDestroy( temp );
-                CleanupStack::PushL( buffer );                                                    
+                else
+                    {
+                    CleanupStack::PopAndDestroy( temp );
+                    }
                 }    	        
 
             // The text is already in visual form, no need for conversion
             conversion = EFalse;
 
-            aLabel.SetTextL( *buffer );            
-                        
-            CleanupStack::PopAndDestroy( 2 ); // buffer, array                                       
+            if ( buffer )
+                {
+                aLabel.SetTextL( *buffer );
+                CleanupStack::PopAndDestroy( buffer );
+                }
+            
+            CleanupStack::PopAndDestroy(); // array                                       
     	    }
         else
             {