kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0001-valgrind-scary-warning-that-the-cairo-font-options-w.patch

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