diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-03-24 22:20:06 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-30 12:03:25 +0000 |
commit | 4ae7ec8c8d22e751b868459e1f51fcecc37dd6b1 (patch) | |
tree | 42ce743ed34d5b36e35768095daa90875dd7c5a3 /vcl | |
parent | 0be4633755e1e2d3639866e074a456e1de0de3a8 (diff) |
vcl: tdf#98812: acquire reference count of WinFontInstances
... when they are inserted in WinSalGraphics::mpWinFontEntry.
Not sure why one of these drops to 0 but is not removed from the
WinSalGraphics when formatting this particular bugdoc.
Acquiring the instances when retaining pointers to them should make
the life cycle a little less insane.
(cherry picked from commit 99207a26df0083851ba8e23be72d5c6974f98a3b)
Change-Id: If1404f46a13736b2a226e198bdf0c3ca8e09bb38
Reviewed-on: https://gerrit.libreoffice.org/23504
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/win/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/win/source/gdi/salgdi3.cxx | 12 | ||||
-rw-r--r-- | vcl/win/source/gdi/winlayout.cxx | 6 |
3 files changed, 20 insertions, 0 deletions
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 3d0046ed9d4f..085f77eed706 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -220,6 +220,8 @@ private: sal_uIntPtr mnFontKernPairCount;// Number of Kerning Pairs of the current Font int mnPenWidth; // Linienbreite + ImplFontEntry* GetWinFontEntry(int nFallbackLevel); + public: HDC getHDC() const { return mhLocalDC; } void setHDC(HDC aNew) { mhLocalDC = aNew; } diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx index 499c0e5084ec..b1f865dcf886 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -1532,12 +1532,23 @@ sal_uInt16 WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel if( mhFonts[i] ) ::DeleteFont( mhFonts[i] ); mhFonts[ i ] = 0; + if (mpWinFontEntry[i]) + { + GetWinFontEntry(i)->m_pFontCache->Release(GetWinFontEntry(i)); + } + mpWinFontEntry[i] = nullptr; + mpWinFontData[i] = nullptr; } mhDefFont = 0; return 0; } DBG_ASSERT( pFont->mpFontData, "WinSalGraphics mpFontData==NULL"); + if (mpWinFontEntry[nFallbackLevel]) + { + GetWinFontEntry(nFallbackLevel)->m_pFontCache->Release(GetWinFontEntry(nFallbackLevel)); + } + pFont->mpFontEntry->m_pFontCache->Acquire(pFont->mpFontEntry); mpWinFontEntry[ nFallbackLevel ] = reinterpret_cast<ImplWinFontEntry*>( pFont->mpFontEntry ); mpWinFontData[ nFallbackLevel ] = static_cast<const ImplWinFontData*>( pFont->mpFontData ); @@ -1560,6 +1571,7 @@ sal_uInt16 WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel ::DeleteFont( mhFonts[i] ); mhFonts[i] = 0; } + // note: removing mpWinFontEntry[i] here has obviously bad effects } } diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index 3b1f081e03b8..d8073fd21fd0 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -1347,6 +1347,7 @@ WinLayout::WinLayout(HDC hDC, const ImplWinFontData& rWFD, ImplWinFontEntry& rWF mrWinFontEntry(rWFE), mbUseOpenGL(bUseOpenGL) { + assert(mrWinFontEntry.mnRefCount > 0); // keep mrWinFontEntry alive mrWinFontEntry.m_pFontCache->Acquire(&mrWinFontEntry); } @@ -4263,6 +4264,11 @@ int WinSalGraphics::GetMinKashidaWidth() return nMinKashida; } +ImplFontEntry * WinSalGraphics::GetWinFontEntry(int const nFallbackLevel) +{ + return mpWinFontEntry[nFallbackLevel]; +} + ImplWinFontEntry::ImplWinFontEntry( FontSelectPattern& rFSD ) : ImplFontEntry( rFSD ) , mpGLyphyAtlas( nullptr ) |