diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-02-29 17:05:11 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-02-29 17:09:34 +0000 |
commit | 8c9823d311fdf8092cc75873e4565325d204a658 (patch) | |
tree | df1ad4fe2f7b80242ecf82b3f5ebf044c32d1070 /vcl/source/gdi/outdev3.cxx | |
parent | 3cc7cbeb0efab138696bb9901b33648025e29a45 (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
Diffstat (limited to 'vcl/source/gdi/outdev3.cxx')
-rwxr-xr-x | vcl/source/gdi/outdev3.cxx | 30 |
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 ); |