summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2021-09-27 18:26:17 +0200
committerThorsten Behrens <thorsten.behrens@allotropia.de>2022-05-18 12:33:50 +0200
commit2c1d1b32f4ddfdffedb27bec5c906c7c8cb26cd6 (patch)
tree9f21ac0783bc18309b8ad96deda8e776a5b6b8fe
parent3571b8e600b24e2e1109cd4c64b615937d3e2cb7 (diff)
tdf#144754 WIN de-assert ReleaseFonts / setFont
DeInitGraphics might already have reset the default HDC font, while the WinSalGraphics still has a font fallback stack. Not sure why this didn't trigger the existing assert before. Quite probably there was an existing lifecycle bug. Regression from commit 42f9d4335bfa4b7299224801fd7ccdd97ae92fbf ("WIN always (de-)init WinSalGraphics") Change-Id: Ie5826e632310a0d69e8f9617cf6f3629bc31f152 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122726 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de> (cherry picked from commit 3476106890ea2a00e6f949c918f6c05e17c66a36) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134516 Tested-by: Thorsten Behrens <thorsten.behrens@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
-rw-r--r--vcl/win/gdi/salfont.cxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 9d8439c7387c..1f0db745639e 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -896,16 +896,22 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont,
void WinSalGraphics::SetFont(LogicalFontInstance* pFont, int nFallbackLevel)
{
+ // check that we don't change the first font while ScopedFont has replaced HFONT
+ assert(!mpWinFontEntry[0].is() || nFallbackLevel != 0 || mpWinFontEntry[0]->GetHFONT());
+ assert(nFallbackLevel >= 0 && nFallbackLevel < MAX_FALLBACK);
+
// return early if there is no new font
if( !pFont )
{
if (!mpWinFontEntry[nFallbackLevel].is())
return;
- // select original DC font
- assert(mhDefFont);
- ::SelectFont(getHDC(), mhDefFont);
- mhDefFont = nullptr;
+ // DeInitGraphics doesn't free the cached fonts, so mhDefFont might be nullptr
+ if (mhDefFont)
+ {
+ ::SelectFont(getHDC(), mhDefFont);
+ mhDefFont = nullptr;
+ }
// release no longer referenced font handles
for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )