tdf#128434 correctly release fonts in destructors
This adds ReleaseFonts() calls to all destructors of SalGraphics and TextRenderImpl derivated classes, which implement SetFont. During destruction a base class can't call into derivated classes, as these are already destructed, so we have to spread these calls manually. Change-Id: Ia57db04f7df665e5205212ce512119e2f60e3379 Reviewed-on: https://gerrit.libreoffice.org/82967 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
This commit is contained in:
parent
e6aac0b637
commit
f8e1f86522
7 changed files with 13 additions and 25 deletions
|
@ -612,6 +612,7 @@ SvpSalGraphics::SvpSalGraphics()
|
|||
|
||||
SvpSalGraphics::~SvpSalGraphics()
|
||||
{
|
||||
ReleaseFonts();
|
||||
}
|
||||
|
||||
void SvpSalGraphics::setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize)
|
||||
|
|
|
@ -32,10 +32,12 @@ class PhysicalFontFace;
|
|||
class TextRenderImpl
|
||||
{
|
||||
public:
|
||||
// can't call ReleaseFonts here, as the destructor just calls this classes SetFont (pure virtual)!
|
||||
virtual ~TextRenderImpl() {}
|
||||
|
||||
virtual void SetTextColor( Color nColor ) = 0;
|
||||
virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) = 0;
|
||||
void ReleaseFonts() { SetFont(nullptr, 0); }
|
||||
virtual void GetFontMetric( ImplFontMetricDataRef&, int nFallbackLevel ) = 0;
|
||||
virtual FontCharMapRef GetFontCharMap() const = 0;
|
||||
virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const = 0;
|
||||
|
|
|
@ -38,13 +38,11 @@ protected:
|
|||
virtual void getSurfaceOffset(double& nDX, double& nDY) = 0;
|
||||
virtual void releaseCairoContext(cairo_t* cr) = 0;
|
||||
|
||||
void setFont(LogicalFontInstance *pEntry, int nFallbackLevel);
|
||||
|
||||
virtual void clipRegion(cairo_t* cr) = 0;
|
||||
|
||||
public:
|
||||
CairoTextRender();
|
||||
|
||||
virtual ~CairoTextRender() override;
|
||||
|
||||
virtual void SetTextColor( Color nColor ) override;
|
||||
virtual void SetFont(LogicalFontInstance*, int nFallbackLevel) override;
|
||||
|
|
|
@ -44,16 +44,7 @@ Qt5Graphics::Qt5Graphics( Qt5Frame *pFrame, QImage *pQImage )
|
|||
m_pWidgetDraw.reset(new Qt5Graphics_Controls());
|
||||
}
|
||||
|
||||
Qt5Graphics::~Qt5Graphics()
|
||||
{
|
||||
// release the text styles
|
||||
for (int i = 0; i < MAX_FALLBACK; ++i)
|
||||
{
|
||||
if (!m_pTextStyle[i])
|
||||
break;
|
||||
m_pTextStyle[i].clear();
|
||||
}
|
||||
}
|
||||
Qt5Graphics::~Qt5Graphics() { ReleaseFonts(); }
|
||||
|
||||
void Qt5Graphics::ChangeQImage(QImage* pQImage)
|
||||
{
|
||||
|
|
|
@ -222,12 +222,7 @@ AquaSalGraphics::~AquaSalGraphics()
|
|||
CGPathRelease( mxClipPath );
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_FALLBACK; ++i)
|
||||
{
|
||||
if (!mpTextStyle[i])
|
||||
break;
|
||||
mpTextStyle[i].clear();
|
||||
}
|
||||
ReleaseFonts();
|
||||
|
||||
if( mpXorEmulation )
|
||||
delete mpXorEmulation;
|
||||
|
|
|
@ -82,6 +82,7 @@ bool SalGraphics::initWidgetDrawBackends(bool bForce)
|
|||
|
||||
SalGraphics::~SalGraphics() COVERITY_NOEXCEPT_FALSE
|
||||
{
|
||||
// can't call ReleaseFonts here, as the destructor just calls this classes SetFont (pure virtual)!
|
||||
}
|
||||
|
||||
#if HAVE_FEATURE_OPENGL
|
||||
|
|
|
@ -81,7 +81,12 @@ CairoTextRender::CairoTextRender()
|
|||
rp = nullptr;
|
||||
}
|
||||
|
||||
void CairoTextRender::setFont(LogicalFontInstance *pEntry, int nFallbackLevel)
|
||||
CairoTextRender::~CairoTextRender()
|
||||
{
|
||||
ReleaseFonts();
|
||||
}
|
||||
|
||||
void CairoTextRender::SetFont(LogicalFontInstance *pEntry, int nFallbackLevel)
|
||||
{
|
||||
// release all no longer needed font resources
|
||||
for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
|
||||
|
@ -380,11 +385,6 @@ bool CairoTextRender::GetFontCapabilities(vcl::FontCapabilities &rGetImplFontCap
|
|||
|
||||
// SalGraphics
|
||||
|
||||
void CairoTextRender::SetFont(LogicalFontInstance *pEntry, int nFallbackLevel)
|
||||
{
|
||||
setFont(pEntry, nFallbackLevel);
|
||||
}
|
||||
|
||||
void
|
||||
CairoTextRender::SetTextColor( Color nColor )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue