diff options
author | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-02-16 12:40:48 +0000 |
---|---|---|
committer | bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-02-16 12:40:48 +0000 |
commit | ee51d1a6e43615ae640410013c36d2d9873e6aa5 (patch) | |
tree | 3afb2eba1a21de92a11dc8f84f622f9154c052f0 /src/ports | |
parent | 6008c656f90026a3b434938454fd2b67cf135e0a (diff) |
Fix TypefaceCache races.
http://codereview.appspot.com/5656066/
git-svn-id: http://skia.googlecode.com/svn/trunk@3205 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports')
-rw-r--r-- | src/ports/SkFontHost_mac_coretext.cpp | 6 | ||||
-rwxr-xr-x | src/ports/SkFontHost_win.cpp | 10 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/ports/SkFontHost_mac_coretext.cpp b/src/ports/SkFontHost_mac_coretext.cpp index e5fedc1615..00463fe460 100644 --- a/src/ports/SkFontHost_mac_coretext.cpp +++ b/src/ports/SkFontHost_mac_coretext.cpp @@ -542,11 +542,9 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace, } NameStyleRec rec = { familyName, style }; - SkTypeface* face = SkTypefaceCache::FindByProc(FindByNameStyle, &rec); + SkTypeface* face = SkTypefaceCache::FindByProcAndRef(FindByNameStyle, &rec); - if (face) { - face->ref(); - } else { + if (NULL == face) { face = NewFromName(familyName, style); if (face) { SkTypefaceCache::Add(face, style); diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp index e78bfbb222..ec7e1b00aa 100755 --- a/src/ports/SkFontHost_win.cpp +++ b/src/ports/SkFontHost_win.cpp @@ -175,10 +175,8 @@ static bool FindByLogFont(SkTypeface* face, SkTypeface::Style requestedStyle, vo SkTypeface* SkCreateTypefaceFromLOGFONT(const LOGFONT& origLF) { LOGFONT lf = origLF; make_canonical(&lf); - SkTypeface* face = SkTypefaceCache::FindByProc(FindByLogFont, &lf); - if (face) { - face->ref(); - } else { + SkTypeface* face = SkTypefaceCache::FindByProcAndRef(FindByLogFont, &lf); + if (NULL == face) { face = LogFontTypeface::Create(lf); SkTypefaceCache::Add(face, get_style(lf)); } @@ -205,7 +203,9 @@ SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { static void ensure_typeface_accessible(SkFontID fontID) { LogFontTypeface* face = (LogFontTypeface*)SkTypefaceCache::FindByID(fontID); - SkFontHost::EnsureTypefaceAccessible(*face); + if (face) { + SkFontHost::EnsureTypefaceAccessible(*face); + } } static void GetLogFontByID(SkFontID fontID, LOGFONT* lf) { |