Stop memory leaks in FontClient. 37/44937/3
authorRichard Underhill <r.underhill@partner.samsung.com>
Thu, 30 Jul 2015 08:34:20 +0000 (09:34 +0100)
committerRichard Underhill <r.underhill@partner.samsung.com>
Thu, 30 Jul 2015 08:34:20 +0000 (09:34 +0100)
Change-Id: Iaa66eeb3ea1d4f454e17f704cd75a1183959f36b
Signed-off-by: Richard Underhill <r.underhill@partner.samsung.com>
text/dali/internal/text-abstraction/font-client-plugin-impl.cpp

index aa6908a..18a4feb 100644 (file)
@@ -315,11 +315,15 @@ FontId FontClient::Plugin::FindDefaultFont( Character charcode,
       // Keep going unless we prefer a different (color) font
       if( !preferColor || foundColor )
       {
+        FcPatternDestroy( match );
+        FcPatternDestroy( pattern );
         break;
       }
     }
-  }
 
+    FcPatternDestroy( match );
+    FcPatternDestroy( pattern );
+  }
   return fontId;
 }
 
@@ -1023,16 +1027,22 @@ bool FontClient::Plugin::IsScalable( const FontFamily& fontFamily, const FontSty
 
   // match the pattern
   FcPattern* match = FcFontMatch( NULL /* use default configure */, fontFamilyPattern, &result );
+  bool isScalable = true;
 
   if( match )
   {
     // Get the path to the font file name.
     FontPath path;
     GetFcString( match, FC_FILE, path );
-    return IsScalable( path );
+    isScalable = IsScalable( path );
+  }
+  else
+  {
+    DALI_LOG_ERROR( "FreeType Cannot check font: %s %s\n", fontFamily.c_str(), fontStyle.c_str() );
   }
-  DALI_LOG_ERROR( "FreeType Cannot check font: %s %s\n", fontFamily.c_str(), fontStyle.c_str() );
-  return true;
+  FcPatternDestroy( fontFamilyPattern );
+  FcPatternDestroy( match );
+  return isScalable;
 }
 
 void FontClient::Plugin::GetFixedSizes( const FontPath& path, Vector< PointSize26Dot6 >& sizes )
@@ -1078,9 +1088,14 @@ void FontClient::Plugin::GetFixedSizes( const FontFamily& fontFamily,
     // Get the path to the font file name.
     FontPath path;
     GetFcString( match, FC_FILE, path );
-    return GetFixedSizes( path, sizes );
+    GetFixedSizes( path, sizes );
+  }
+  else
+  {
+    DALI_LOG_ERROR( "FreeType Cannot check font: %s %s\n", fontFamily.c_str(), fontStyle.c_str() );
   }
-  DALI_LOG_ERROR( "FreeType Cannot check font: %s %s\n", fontFamily.c_str(), fontStyle.c_str() );
+  FcPatternDestroy( match );
+  FcPatternDestroy( fontFamilyPattern );
 }
 
 } // namespace Internal