fa8cdad
From 78c32c11b0911b905fced7519d8881262d6fb4a0 Mon Sep 17 00:00:00 2001
fa8cdad
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
fa8cdad
Date: Tue, 1 Dec 2015 20:35:28 +0000
fa8cdad
Subject: [PATCH] valgrind: scary warning that the cairo font options were
fa8cdad
 deleted before use
fa8cdad
fa8cdad
(cherry picked from commit 3520b0f82aa2146958fbc1bda1cf7e9b5beb9a5d)
fa8cdad
fa8cdad
Change-Id: I58427aafb30eca64a67bcf7dd9a7738d8da3e085
fa8cdad
---
fa8cdad
 include/vcl/settings.hxx                      |  3 ---
fa8cdad
 vcl/inc/salinst.hxx                           |  4 ++++
fa8cdad
 vcl/inc/unx/gtk/gtkinst.hxx                   |  2 ++
fa8cdad
 vcl/source/app/settings.cxx                   | 16 ----------------
fa8cdad
 vcl/unx/generic/gdi/cairotextrender.cxx       | 12 ++++++------
fa8cdad
 vcl/unx/gtk/app/gtkinst.cxx                   |  5 +++++
fa8cdad
 vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx      |  4 ----
fa8cdad
 vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx |  3 ---
fa8cdad
 8 files changed, 17 insertions(+), 32 deletions(-)
fa8cdad
fa8cdad
diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
fa8cdad
index 006e758..6df8b0d 100644
fa8cdad
--- a/include/vcl/settings.hxx
fa8cdad
+++ b/include/vcl/settings.hxx
fa8cdad
@@ -442,9 +442,6 @@ public:
fa8cdad
     void                            SetPrimaryButtonWarpsSlider( bool bPrimaryButtonWarpsSlider );
fa8cdad
     bool                            GetPrimaryButtonWarpsSlider() const;
fa8cdad
 
fa8cdad
-    void                            SetCairoFontOptions( const void *pOptions );
fa8cdad
-    const void*                     GetCairoFontOptions() const;
fa8cdad
-
fa8cdad
     void                            SetAppFont( const vcl::Font& rFont );
fa8cdad
     const vcl::Font&                GetAppFont() const;
fa8cdad
 
fa8cdad
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
fa8cdad
index f49bb4c..d89b1dd 100644
fa8cdad
--- a/vcl/inc/salinst.hxx
fa8cdad
+++ b/vcl/inc/salinst.hxx
fa8cdad
@@ -60,6 +60,8 @@ enum class VclInputFlags;
fa8cdad
 
fa8cdad
 enum SalYieldResult { EVENT, TIMEOUT };
fa8cdad
 
fa8cdad
+typedef struct _cairo_font_options cairo_font_options_t;
fa8cdad
+
fa8cdad
 class VCL_PLUGIN_PUBLIC SalInstance
fa8cdad
 {
fa8cdad
 private:
fa8cdad
@@ -181,6 +183,8 @@ public:
fa8cdad
     virtual void            updatePrinterUpdate() {}
fa8cdad
     virtual void            jobStartedPrinterUpdate() {}
fa8cdad
     virtual void            jobEndedPrinterUpdate() {}
fa8cdad
+
fa8cdad
+    virtual const cairo_font_options_t* GetCairoFontOptions() { return nullptr; }
fa8cdad
 };
fa8cdad
 
fa8cdad
 // called from SVMain
fa8cdad
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
fa8cdad
index 189b6900..1ea6f8e 100644
fa8cdad
--- a/vcl/inc/unx/gtk/gtkinst.hxx
fa8cdad
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
fa8cdad
@@ -98,6 +98,8 @@ public:
fa8cdad
     virtual css::uno::Reference< css::uno::XInterface > CreateClipboard( const css::uno::Sequence< css::uno::Any >& i_rArguments ) SAL_OVERRIDE;
fa8cdad
 #endif
fa8cdad
 
fa8cdad
+    virtual const cairo_font_options_t* GetCairoFontOptions() override;
fa8cdad
+
fa8cdad
     void                        RemoveTimer (SalTimer *pTimer);
fa8cdad
 
fa8cdad
     // for managing a mirror of the in-flight un-dispatched gdk event queue
fa8cdad
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
fa8cdad
index 664f755..2f457c5 100644
fa8cdad
--- a/vcl/source/app/settings.cxx
fa8cdad
+++ b/vcl/source/app/settings.cxx
fa8cdad
@@ -191,7 +191,6 @@ struct ImplStyleData
fa8cdad
     bool                            mbPrimaryButtonWarpsSlider;
fa8cdad
     DialogStyle                     maDialogStyle;
fa8cdad
     FrameStyle                      maFrameStyle;
fa8cdad
-    const void*                     mpFontOptions;
fa8cdad
 
fa8cdad
     sal_uInt16                      mnEdgeBlending;
fa8cdad
     Color                           maEdgeBlendingTopLeftColor;
fa8cdad
@@ -546,7 +545,6 @@ ImplStyleData::ImplStyleData() :
fa8cdad
     mbAutoMnemonic              = true;
fa8cdad
     mnToolbarIconSize           = ToolbarIconSize::Unknown;
fa8cdad
     meUseImagesInMenus          = TRISTATE_INDET;
fa8cdad
-    mpFontOptions              = NULL;
fa8cdad
     mnEdgeBlending = 35;
fa8cdad
     maEdgeBlendingTopLeftColor = RGB_COLORDATA(0xC0, 0xC0, 0xC0);
fa8cdad
     maEdgeBlendingBottomRightColor = RGB_COLORDATA(0x40, 0x40, 0x40);
fa8cdad
@@ -667,7 +665,6 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
fa8cdad
     mnToolbarIconSize           = rData.mnToolbarIconSize;
fa8cdad
     mIconThemeScanner.reset(new vcl::IconThemeScanner(*rData.mIconThemeScanner));
fa8cdad
     mIconThemeSelector.reset(new vcl::IconThemeSelector(*rData.mIconThemeSelector));
fa8cdad
-    mpFontOptions               = rData.mpFontOptions;
fa8cdad
     mnEdgeBlending              = rData.mnEdgeBlending;
fa8cdad
     maEdgeBlendingTopLeftColor  = rData.maEdgeBlendingTopLeftColor;
fa8cdad
     maEdgeBlendingBottomRightColor = rData.maEdgeBlendingBottomRightColor;
fa8cdad
@@ -1547,19 +1544,6 @@ StyleSettings::GetPrimaryButtonWarpsSlider() const
fa8cdad
 }
fa8cdad
 
fa8cdad
 void
fa8cdad
-StyleSettings::SetCairoFontOptions( const void *pOptions )
fa8cdad
-{
fa8cdad
-    CopyData();
fa8cdad
-    mxData->mpFontOptions = pOptions;
fa8cdad
-}
fa8cdad
-
fa8cdad
-const void*
fa8cdad
-StyleSettings::GetCairoFontOptions() const
fa8cdad
-{
fa8cdad
-    return mxData->mpFontOptions;
fa8cdad
-}
fa8cdad
-
fa8cdad
-void
fa8cdad
 StyleSettings::SetAppFont( const vcl::Font& rFont )
fa8cdad
 {
fa8cdad
     CopyData();
fa8cdad
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
fa8cdad
index 2e3aa90..4ffddf3 100644
fa8cdad
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
fa8cdad
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
fa8cdad
@@ -214,8 +214,9 @@ void CairoTextRender::DrawServerFontLayout( const ServerFontLayout& rLayout )
fa8cdad
         return;
fa8cdad
     }
fa8cdad
 
fa8cdad
-    if (const void *pOptions = Application::GetSettings().GetStyleSettings().GetCairoFontOptions())
fa8cdad
-        cairo_set_font_options(cr, static_cast<const cairo_font_options_t*>(pOptions));
fa8cdad
+    ImplSVData* pSVData = ImplGetSVData();
fa8cdad
+    if (const cairo_font_options_t* pFontOptions = pSVData->mpDefInst->GetCairoFontOptions())
fa8cdad
+        cairo_set_font_options(cr, pFontOptions);
fa8cdad
 
fa8cdad
     double nDX, nDY;
fa8cdad
     getSurfaceOffset(nDX, nDY);
fa8cdad
@@ -462,12 +463,11 @@ void CairoTextRender::GetDevFontList( PhysicalFontCollection* pFontCollection )
fa8cdad
 
fa8cdad
 void cairosubcallback(void* pPattern)
fa8cdad
 {
fa8cdad
-    const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
fa8cdad
-    const void* pFontOptions = rStyleSettings.GetCairoFontOptions();
fa8cdad
+    ImplSVData* pSVData = ImplGetSVData();
fa8cdad
+    const cairo_font_options_t* pFontOptions = pSVData->mpDefInst->GetCairoFontOptions();
fa8cdad
     if( !pFontOptions )
fa8cdad
         return;
fa8cdad
-    cairo_ft_font_options_substitute(static_cast<const cairo_font_options_t*>(pFontOptions),
fa8cdad
-        static_cast<FcPattern*>(pPattern));
fa8cdad
+    cairo_ft_font_options_substitute(pFontOptions, static_cast<FcPattern*>(pPattern));
fa8cdad
 }
fa8cdad
 
fa8cdad
 ImplFontOptions* GetFCFontOptions( const ImplFontAttributes& rFontAttributes, int nSize)
fa8cdad
diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx
fa8cdad
index 9242b88..7d8111c 100644
fa8cdad
--- a/vcl/unx/gtk/app/gtkinst.cxx
fa8cdad
+++ b/vcl/unx/gtk/app/gtkinst.cxx
fa8cdad
@@ -473,4 +473,9 @@ GtkInstance::getPrintWrapper() const
fa8cdad
     return m_xPrintWrapper;
fa8cdad
 }
fa8cdad
 
fa8cdad
+const cairo_font_options_t* GtkInstance::GetCairoFontOptions()
fa8cdad
+{
fa8cdad
+    return gdk_screen_get_font_options(gdk_screen_get_default());
fa8cdad
+}
fa8cdad
+
fa8cdad
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
fa8cdad
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
fa8cdad
index 1220596..aa53b65 100644
fa8cdad
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
fa8cdad
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
fa8cdad
@@ -3928,7 +3928,6 @@ void GtkSalGraphics::refreshFontconfig( GtkSettings *pSettings )
fa8cdad
 
fa8cdad
 void GtkSalGraphics::updateSettings( AllSettings& rSettings )
fa8cdad
 {
fa8cdad
-    GdkScreen* pScreen = gtk_widget_get_screen( m_pWindow );
fa8cdad
     gtk_widget_ensure_style( m_pWindow );
fa8cdad
     GtkStyle* pStyle = gtk_widget_get_style( m_pWindow );
fa8cdad
     GtkSettings* pSettings = gtk_widget_get_settings( m_pWindow );
fa8cdad
@@ -4257,9 +4256,6 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
fa8cdad
 
fa8cdad
     aStyleSet.SetToolbarIconSize( ToolbarIconSize::Large );
fa8cdad
 
fa8cdad
-    const cairo_font_options_t* pNewOptions = gdk_screen_get_font_options( pScreen );
fa8cdad
-    aStyleSet.SetCairoFontOptions( pNewOptions );
fa8cdad
-
fa8cdad
     // finally update the collected settings
fa8cdad
     rSettings.SetStyleSettings( aStyleSet );
fa8cdad
 }
fa8cdad
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
fa8cdad
index 90d8734..2d639bf 100644
fa8cdad
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
fa8cdad
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
fa8cdad
@@ -1452,7 +1452,6 @@ static inline ::Color getColorFromColor( const GdkColor& rCol )
fa8cdad
 
fa8cdad
 void GtkSalGraphics::updateSettings( AllSettings& rSettings )
fa8cdad
 {
fa8cdad
-    GdkScreen* pScreen = gtk_widget_get_screen( mpWindow );
fa8cdad
     GtkStyleContext* pStyle = gtk_widget_get_style_context( mpWindow );
fa8cdad
     GtkSettings* pSettings = gtk_widget_get_settings( mpWindow );
fa8cdad
     StyleSettings aStyleSet = rSettings.GetStyleSettings();
fa8cdad
@@ -1801,8 +1800,6 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
fa8cdad
 
fa8cdad
     aStyleSet.SetToolbarIconSize( ToolbarIconSize::Large );
fa8cdad
 
fa8cdad
-    const cairo_font_options_t* pNewOptions = gdk_screen_get_font_options(pScreen);
fa8cdad
-    aStyleSet.SetCairoFontOptions( pNewOptions );
fa8cdad
     // finally update the collected settings
fa8cdad
     rSettings.SetStyleSettings( aStyleSet );
fa8cdad
     gchar* pThemeName = NULL;
fa8cdad
-- 
fa8cdad
2.5.0
fa8cdad