vcl/inc/win/salgdi.h | 2 ++ vcl/win/source/gdi/salgdi3.cxx | 12 ++++++++++++ vcl/win/source/gdi/winlayout.cxx | 6 ++++++ 3 files changed, 20 insertions(+)
New commits: commit 4ae7ec8c8d22e751b868459e1f51fcecc37dd6b1 Author: Michael Stahl <mst...@redhat.com> Date: Thu Mar 24 22:20:06 2016 +0100 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 <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 3d0046e..085f77e 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 499c0e5..b1f865d 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 3b1f081..d8073fd 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 ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits