contentstorage/casrv/cawidgetscanner/src/cawidgetscannerparser.cpp
changeset 115 3ab5c078b490
parent 109 e0aa398e6810
--- a/contentstorage/casrv/cawidgetscanner/src/cawidgetscannerparser.cpp	Wed Aug 18 10:05:49 2010 +0300
+++ b/contentstorage/casrv/cawidgetscanner/src/cawidgetscannerparser.cpp	Thu Sep 02 20:45:03 2010 +0300
@@ -638,10 +638,12 @@
         const TDesC& aPackageUid, CCaWidgetDescription* aWidgetDescriptor,
         TChar& aDrive )
     {
-    aWidgetDescriptor->SetIconUriL( 
-        *GetThemableGraphicsNameLC(aElement, aPackageUid, aDrive ) );
+    HBufC *const graphicsName = 
+        GetThemableGraphicsNameLC(aElement, aPackageUid, aDrive );   
+    
+    aWidgetDescriptor->SetIconUriL( *graphicsName );
    
-    CleanupStack::PopAndDestroy( );
+    CleanupStack::PopAndDestroy( graphicsName );
     }
 
 // ----------------------------------------------------------------------------
@@ -654,10 +656,12 @@
         CCaWidgetDescription* aWidgetDescriptor,
         TChar& aDrive )
     {
-    aWidgetDescriptor->SetPreviewImageNameL( 
-        *GetThemableGraphicsNameLC(aElement, aPackageUid, aDrive ) );
+    HBufC *const graphicsName = 
+        GetThemableGraphicsNameLC(aElement, aPackageUid, aDrive );
     
-    CleanupStack::PopAndDestroy();
+    aWidgetDescriptor->SetPreviewImageNameL( *graphicsName );
+    
+    CleanupStack::PopAndDestroy( graphicsName );
     }
 
 // ----------------------------------------------------------------------------
@@ -731,47 +735,42 @@
     {
     RBuf graphicsName;
     graphicsName.CleanupClosePushL();
-    HBufC* result; 
+
+    RBuf elementText;
+    elementText.CleanupClosePushL();
+    
+    elementText.Assign( 
+        CnvUtfConverter::ConvertToUnicodeFromUtf8L( aElement.Text() ) );
+    
+    if ( TParsePtrC(elementText).Ext() != KNullDesC )
+        {
+        HBufC* const manifestDirectoryPath( 
+            GetManifestDirectoryPathLC( aPackageUid, aDrive ) );
+        
+        graphicsName.CreateL( manifestDirectoryPath->Length() + 
+            elementText.Length() );
+        graphicsName.Append( *manifestDirectoryPath );
+        
+        CleanupStack::PopAndDestroy( manifestDirectoryPath );
+        }
+    else
+        {   
+        graphicsName.CreateL( elementText.Length() );
+        }
+    
+    graphicsName.Append( elementText );
 
     
-    if ( aElement.Text() != KNullDesC8 )
-        {
-        RBuf elementText;
-        elementText.CleanupClosePushL();
-        
-        elementText.Assign( 
-            CnvUtfConverter::ConvertToUnicodeFromUtf8L( aElement.Text() ) );
-        
-        if ( TParsePtrC(elementText).Ext() != KNullDesC )
-            {
-            HBufC* const manifestDirectoryPath( 
-                GetManifestDirectoryPathLC( aPackageUid, aDrive ) );
-            
-            graphicsName.CreateL( manifestDirectoryPath->Length() + 
-                elementText.Length() );
-            graphicsName.Append( *manifestDirectoryPath );
-            
-            CleanupStack::PopAndDestroy( manifestDirectoryPath );
-            }
-        else
-            {   
-            graphicsName.CreateL( elementText.Length() );
-            }
-        
-        graphicsName.Append( elementText );
-        result = HBufC::NewL( graphicsName.Length() ) ;
-        *result = graphicsName;
-        
-        CleanupStack::PopAndDestroy( &elementText );
-        }
-    else
-    	{
-        result = HBufC::NewL( 1 ) ;
-    	}
-        CleanupStack::PopAndDestroy( &graphicsName );
-        CleanupStack::PushL( result );
-        
-        return result;
+    CleanupStack::PopAndDestroy( &elementText );
+    
+    HBufC *result = HBufC::NewL( graphicsName.Length() ) ;
+    *result = graphicsName;
+    
+    CleanupStack::PopAndDestroy( &graphicsName );
+    
+    CleanupStack::PushL( result );
+    
+    return result;
     }