diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-03-24 22:20:06 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-31 13:46:05 +0000 |
commit | 988847aae823c7ea47a9925f1a40cdd61cc59f5c (patch) | |
tree | 063609ecaf07b8bd80c97f3500e6f4d63a9417ee | |
parent | 8de829c25511add434373e58e69df997d25e1e5c (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)
Reviewed-on: https://gerrit.libreoffice.org/23504
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
(cherry picked from commit 4ae7ec8c8d22e751b868459e1f51fcecc37dd6b1)
tdf#98812: follow-up
pFont->mpFontInstance can be NULL.
Reviewed-on: https://gerrit.libreoffice.org/23654
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
(cherry picked from commit 9fa87bb1a42c45446f78b4d8c8096d7ce90a8022)
Signed-off-by: Michael Stahl <mstahl@redhat.com>
(cherry picked from commit 4ab36bbd1816d6f297892a638e6826f28ca87150)
Change-Id: If1404f46a13736b2a226e198bdf0c3ca8e09bb38
Reviewed-on: https://gerrit.libreoffice.org/23651
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | vcl/inc/win/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/win/source/gdi/salgdi3.cxx | 17 | ||||
-rw-r--r-- | vcl/win/source/gdi/winlayout.cxx | 6 |
3 files changed, 25 insertions, 0 deletions
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 18b7ecfb3c2e..790c3f9a53f4 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 419fa26a9dc3..2b78abc58292 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 261e1b0387a9..b28fa679cb86 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 ) |