aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-12 15:25:29 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-12 15:25:29 +0000
commit9fc5c68823c7e39e4769a41713ce070a7780df29 (patch)
tree535b70eab35005f1185b536479a8cb52495e04f6
parent940ccc819b821b4e7849491df70f4597318e1fa8 (diff)
Fix leak detected in FontMgrMatchGM::onDraw by Valgrind.
git-svn-id: http://skia.googlecode.com/svn/trunk@12242 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--gm/fontmgr.cpp10
-rw-r--r--include/ports/SkFontMgr.h5
2 files changed, 9 insertions, 6 deletions
diff --git a/gm/fontmgr.cpp b/gm/fontmgr.cpp
index 06288b2ab3..4b64821e7e 100644
--- a/gm/fontmgr.cpp
+++ b/gm/fontmgr.cpp
@@ -162,18 +162,16 @@ protected:
"Helvetica Neue", "Arial"
};
- SkFontStyleSet* fset = NULL;
+ SkAutoTUnref<SkFontStyleSet> fset;
for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); ++i) {
- fset = fFM->matchFamily(gNames[i]);
- if (fset && fset->count() > 0) {
+ fset.reset(fFM->matchFamily(gNames[i]));
+ if (fset->count() > 0) {
break;
}
}
-
- if (NULL == fset) {
+ if (NULL == fset.get()) {
return;
}
- SkAutoUnref aur(fset);
canvas->translate(20, 40);
this->exploreFamily(canvas, paint, fset);
diff --git a/include/ports/SkFontMgr.h b/include/ports/SkFontMgr.h
index 6e9f56f545..accb0c5860 100644
--- a/include/ports/SkFontMgr.h
+++ b/include/ports/SkFontMgr.h
@@ -41,6 +41,10 @@ public:
void getFamilyName(int index, SkString* familyName);
SkFontStyleSet* createStyleSet(int index);
+ /**
+ * The caller must call unref() on the returned object.
+ * Never returns NULL; will return an empty set if the name is not found.
+ */
SkFontStyleSet* matchFamily(const char familyName[]);
/**
@@ -89,6 +93,7 @@ protected:
virtual void onGetFamilyName(int index, SkString* familyName) = 0;
virtual SkFontStyleSet* onCreateStyleSet(int index) = 0;
+ /** May return NULL if the name is not found. */
virtual SkFontStyleSet* onMatchFamily(const char familyName[]) = 0;
virtual SkTypeface* onMatchFamilyStyle(const char familyName[],