vcl/inc/win/salgdi.h | 2 ++ vcl/win/source/gdi/salgdi3.cxx | 17 +++++++++++++++++ vcl/win/source/gdi/winlayout.cxx | 6 ++++++ 3 files changed, 25 insertions(+)
New commits: commit 988847aae823c7ea47a9925f1a40cdd61cc59f5c Author: Michael Stahl <[email protected]> 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) Reviewed-on: https://gerrit.libreoffice.org/23504 Tested-by: Jenkins <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> (cherry picked from commit 4ae7ec8c8d22e751b868459e1f51fcecc37dd6b1) tdf#98812: follow-up pFont->mpFontInstance can be NULL. Reviewed-on: https://gerrit.libreoffice.org/23654 Tested-by: Jenkins <[email protected]> Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit 9fa87bb1a42c45446f78b4d8c8096d7ce90a8022) Signed-off-by: Michael Stahl <[email protected]> (cherry picked from commit 4ab36bbd1816d6f297892a638e6826f28ca87150) Change-Id: If1404f46a13736b2a226e198bdf0c3ca8e09bb38 Reviewed-on: https://gerrit.libreoffice.org/23651 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Miklos Vajna <[email protected]> diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 18b7ecf..790c3f9 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -216,6 +216,8 @@ private: ImplFontAttrCache* mpFontAttrCache; // Cache font attributes from files in so/share/fonts 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 419fa26a..2b78abc 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -1522,12 +1522,28 @@ 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)); + } + // WinSalGraphics::GetEmbedFontData does not set mpFontInstance/mpFontEntry + // since it is interested in font file data only. + if (pFont->mpFontEntry) + { + pFont->mpFontEntry->m_pFontCache->Acquire(pFont->mpFontEntry); + } mpWinFontEntry[ nFallbackLevel ] = reinterpret_cast<ImplWinFontEntry*>( pFont->mpFontEntry ); mpWinFontData[ nFallbackLevel ] = static_cast<const ImplWinFontData*>( pFont->mpFontData ); @@ -1550,6 +1566,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 261e1b0..b28fa67 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -475,6 +475,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); } @@ -2527,6 +2528,11 @@ int WinSalGraphics::GetMinKashidaWidth() return nMinKashida; } +ImplFontEntry * WinSalGraphics::GetWinFontEntry(int const nFallbackLevel) +{ + return mpWinFontEntry[nFallbackLevel]; +} + ImplWinFontEntry::ImplWinFontEntry( FontSelectPattern& rFSD ) : ImplFontEntry( rFSD ) , maWidthMap( 512 ) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
