diff options
author | Jan-Marek Glogowski <jan-marek.glogowski@extern.cib.de> | 2019-11-18 16:04:24 +0000 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2019-11-21 15:21:22 +0100 |
commit | 41f2ec60825bc71686f506178733a885373d6ddb (patch) | |
tree | 508fe2a08a1f0f9a54741ad813b5d9115ea6cc1a | |
parent | 083d98d73379f864a0d3cb9695e7c7ad0febce1c (diff) |
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>
(cherry picked from commit f8e1f8652255cadd80a991aa3e059ee631b333b8)
Reviewed-on: https://gerrit.libreoffice.org/83149
(cherry picked from commit a00bdc999344db34d5926dc77ed5ca895295b0ee)
Reviewed-on: https://gerrit.libreoffice.org/83197
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r-- | vcl/headless/svpgdi.cxx | 1 | ||||
-rw-r--r-- | vcl/inc/textrender.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/cairotextrender.hxx | 4 | ||||
-rw-r--r-- | vcl/qt5/Qt5Graphics.cxx | 11 | ||||
-rw-r--r-- | vcl/quartz/salgdi.cxx | 7 | ||||
-rw-r--r-- | vcl/source/gdi/salgdilayout.cxx | 1 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/cairotextrender.cxx | 12 |
7 files changed, 13 insertions, 25 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index 467de73597e6..8a445b2f209a 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -607,6 +607,7 @@ SvpSalGraphics::SvpSalGraphics() SvpSalGraphics::~SvpSalGraphics() { + ReleaseFonts(); } void SvpSalGraphics::setSurface(cairo_surface_t* pSurface, const basegfx::B2IVector& rSize) diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx index 063b5d4462b2..99360a5521b2 100644 --- a/vcl/inc/textrender.hxx +++ b/vcl/inc/textrender.hxx @@ -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 const FontCharMapRef GetFontCharMap() const = 0; virtual bool GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const = 0; diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx index ca9cfcd8da80..6b011a01874e 100644 --- a/vcl/inc/unx/cairotextrender.hxx +++ b/vcl/inc/unx/cairotextrender.hxx @@ -42,13 +42,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; diff --git a/vcl/qt5/Qt5Graphics.cxx b/vcl/qt5/Qt5Graphics.cxx index 5192f0b42416..8228699a2602 100644 --- a/vcl/qt5/Qt5Graphics.cxx +++ b/vcl/qt5/Qt5Graphics.cxx @@ -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) { diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index 846b7abbbc49..8d7308fd70cc 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -223,12 +223,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; diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx index 789e323f33de..97ba1aa656f0 100644 --- a/vcl/source/gdi/salgdilayout.cxx +++ b/vcl/source/gdi/salgdilayout.cxx @@ -83,6 +83,7 @@ bool SalGraphics::initWidgetDrawBackends(bool bForce) SalGraphics::~SalGraphics() { + // can't call ReleaseFonts here, as the destructor just calls this classes SetFont (pure virtual)! } #if HAVE_FEATURE_OPENGL diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index aa006fa7c5d3..087135652c07 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -84,7 +84,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 ) @@ -384,11 +389,6 @@ bool CairoTextRender::GetFontCapabilities(vcl::FontCapabilities &rGetImplFontCap // SalGraphics -void CairoTextRender::SetFont(LogicalFontInstance *pEntry, int nFallbackLevel) -{ - setFont(pEntry, nFallbackLevel); -} - void CairoTextRender::SetTextColor( Color nColor ) { |