[Libreoffice-commits] core.git: vcl/headless vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 19 02:14:16 UTC 2019


 vcl/headless/svpgdi.cxx                 |    1 +
 vcl/inc/textrender.hxx                  |    2 ++
 vcl/inc/unx/cairotextrender.hxx         |    4 +---
 vcl/qt5/Qt5Graphics.cxx                 |   11 +----------
 vcl/quartz/salgdi.cxx                   |    7 +------
 vcl/source/gdi/salgdilayout.cxx         |    1 +
 vcl/unx/generic/gdi/cairotextrender.cxx |   12 ++++++------
 7 files changed, 13 insertions(+), 25 deletions(-)

New commits:
commit f8e1f8652255cadd80a991aa3e059ee631b333b8
Author:     Jan-Marek Glogowski <jan-marek.glogowski at extern.cib.de>
AuthorDate: Mon Nov 18 16:04:24 2019 +0000
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Tue Nov 19 03:13:33 2019 +0100

    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 at fbihome.de>

diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 57f66d4fabf6..e34678a93932 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -612,6 +612,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 742d8445299b..1aec8fba2301 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 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 33b1a622945e..c0882bc35f86 100644
--- a/vcl/inc/unx/cairotextrender.hxx
+++ b/vcl/inc/unx/cairotextrender.hxx
@@ -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;
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 8884d0bd9f3b..b6df53319e28 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -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;
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index b0fefa665bd5..de11058e4507 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -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
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 3b1c7f24f01a..9610a73bc1d6 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -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 )
 {


More information about the Libreoffice-commits mailing list