summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-02-29 17:05:11 +0000
committerCaolán McNamara <caolanm@redhat.com>2012-02-29 17:09:34 +0000
commit8c9823d311fdf8092cc75873e4565325d204a658 (patch)
treedf1ad4fe2f7b80242ecf82b3f5ebf044c32d1070
parent3cc7cbeb0efab138696bb9901b33648025e29a45 (diff)
we use mpFontData->IsSymbolFont() in our comparison to detect symbol fonts
If we change that between cache lookup and insert we run the risk of invalidating the results of our lookup. This should fix some hard to replicate reference count nasties
-rwxr-xr-xvcl/source/gdi/outdev3.cxx30
1 files changed, 25 insertions, 5 deletions
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index 4c0123f13959..d9367c0cbcae 100755
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -2385,18 +2385,38 @@ ImplFontEntry* ImplFontCache::GetFontEntry( ImplDevFontList* pFontList,
}
}
+ ImplFontData* pFontData = NULL;
+
+ if (!pEntry && pFontFamily)// no cache hit => find the best matching physical font face
+ {
+ bool bOrigWasSymbol = aFontSelData.mpFontData && aFontSelData.mpFontData->IsSymbolFont();
+ pFontData = pFontFamily->FindBestFontFace( aFontSelData );
+ aFontSelData.mpFontData = pFontData;
+ bool bNewIsSymbol = aFontSelData.mpFontData && aFontSelData.mpFontData->IsSymbolFont();
+
+ if (bNewIsSymbol || bOrigWasSymbol)
+ {
+ // it is possible, though generally unlikely, that at this point we
+ // will attempt to use a symbol font as a last-ditch fallback for a
+ // non-symbol font request or vice versa, and by changing
+ // aFontSelData.mpFontData to/from a symbol font we may now find
+ // something in the cache that can be reused which previously
+ // wasn't a candidate
+ FontInstanceList::iterator it = maFontInstanceList.find( aFontSelData );
+ if( it != maFontInstanceList.end() )
+ pEntry = (*it).second;
+ }
+ }
+
if( pEntry ) // cache hit => use existing font instance
{
// increase the font instance's reference count
if( !pEntry->mnRefCount++ )
--mnRef0Count;
}
- else if (pFontFamily)// no cache hit => create a new font instance
- {
- // find the best matching physical font face
- ImplFontData* pFontData = pFontFamily->FindBestFontFace( aFontSelData );
- aFontSelData.mpFontData = pFontData;
+ if (!pEntry && pFontData)// still no cache hit => create a new font instance
+ {
// create a new logical font instance from this physical font face
pEntry = pFontData->CreateFontInstance( aFontSelData );