Kaydet (Commit) 3d6424a7 authored tarafından Caolán McNamara's avatar Caolán McNamara

Related: rhbz#761009 lp#766153 lp#892904 HandleFontOptions crash

The mpServerFont member of a ImplServerFontEntry must not be deleted while the
ImplServerFontEntry still exists

see also 39cbce55 for another reason a crash in
the same place can happen.  Its impossible from traces in crashes before
39cbce55 was fixed to distinguish those crashes
from this crash.

This crash is a regression due to 7a416820
where we went from modifying pServerFont in X11SalGraphics::setFont directly to
modifying it/a-different-one indirectly via ImplServerFontEntry

The various font caches and font thing lifecycles of LibreOffice are somewhat
confusing.

This crash had eluded me for years, to reproduce:
insert->special chars->select a font with loads of glyphs, i.e. "AR PL UKai CN"
click on the first row of glyphs and hold down page-down until you hit the
bottom, then page-up until you hit the top. Pre patch it won't survive the
whole down+up (and valgrind will moan quite a bit)

Change-Id: Ifde0cb375f487c556b04a640d77765a7dc2f0913
üst fe6c9239
......@@ -411,9 +411,22 @@ ImplServerFontEntry::ImplServerFontEntry( FontSelectPattern& rFSD )
// -----------------------------------------------------------------------
void ImplServerFontEntry::SetServerFont(ServerFont* p)
{
if (p == mpServerFont)
return;
if (mpServerFont)
mpServerFont->Release();
mpServerFont = p;
if (mpServerFont)
mpServerFont->AddRef();
}
ImplServerFontEntry::~ImplServerFontEntry()
{
// TODO: remove the ServerFont here instead of in the GlyphCache
if (mpServerFont)
mpServerFont->Release();
}
// =======================================================================
......
......@@ -225,6 +225,7 @@ public:
private:
friend class GlyphCache;
friend class ServerFontLayout;
friend class ImplServerFontEntry;
friend class X11SalGraphics;
void AddRef() const { ++mnRefCount; }
......@@ -302,7 +303,7 @@ private:
public:
ImplServerFontEntry( FontSelectPattern& );
virtual ~ImplServerFontEntry();
void SetServerFont( ServerFont* p) { mpServerFont = p; }
void SetServerFont(ServerFont* p);
void HandleFontOptions();
};
......
......@@ -194,10 +194,10 @@ bool X11SalGraphics::setFont( const FontSelectPattern *pEntry, int nFallbackLeve
// apply font specific-hint settings if needed
// TODO: also disable it for reference devices
if( !bPrinter_ )
{
ImplServerFontEntry* pSFE = static_cast<ImplServerFontEntry*>( pEntry->mpFontEntry );
pSFE->HandleFontOptions();
if( !bPrinter_ )
{
ImplServerFontEntry* pSFE = static_cast<ImplServerFontEntry*>( pEntry->mpFontEntry );
pSFE->HandleFontOptions();
}
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment