[Libreoffice-commits] core.git: 2 commits - cui/source include/svx include/vcl svx/source vcl/headless vcl/inc vcl/qt5 vcl/source vcl/unx

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Aug 21 19:06:40 UTC 2018


 cui/source/tabpages/tppattern.cxx |    5 +-
 include/svx/xbtmpit.hxx           |    6 ---
 include/vcl/BitmapTools.hxx       |    6 +++
 svx/source/dialog/dlgctrl.cxx     |    3 +
 svx/source/xoutdev/xattrbmp.cxx   |   61 -----------------------------------
 svx/source/xoutdev/xtabptrn.cxx   |    9 ++---
 vcl/headless/svpdata.cxx          |    3 +
 vcl/headless/svpinst.cxx          |    4 +-
 vcl/inc/headless/svpinst.hxx      |    2 -
 vcl/inc/qt5/Qt5Instance.hxx       |    2 -
 vcl/inc/unx/geninst.h             |    4 +-
 vcl/inc/unx/gtk/gtkinst.hxx       |    2 -
 vcl/inc/unx/salinst.h             |    2 -
 vcl/qt5/Qt5Instance.cxx           |    6 +--
 vcl/source/bitmap/BitmapTools.cxx |   65 ++++++++++++++++++++++++++++++++++++++
 vcl/unx/generic/app/salinst.cxx   |    6 +--
 vcl/unx/gtk/gtkinst.cxx           |   12 ++-----
 vcl/unx/kde4/KDESalInstance.cxx   |    4 +-
 vcl/unx/kde4/KDESalInstance.hxx   |    2 -
 vcl/unx/kde4/main.cxx             |    2 -
 20 files changed, 107 insertions(+), 99 deletions(-)

New commits:
commit cd8dd48bf89d800c012afb04b16281ed8b261de9
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Aug 21 16:07:55 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Aug 21 21:06:24 2018 +0200

    tdf#119282 Area tab, Pattern color change
    
    regression from
    
        commit ccd316d1cb310734848bd20244f509024b549b8c
            use VirtualDevice in createHistorical8x8FromArray
    
    Move the code inside vcl so we don't need to expose BitmapWriteAccess.
    
    I tried to detect this thing by counting the number of independent
    colors in the bitmap, but that didn't work. It is used from more than
    one place, and appears to be very determined that it needs a 2-color
    palette to work properly.
    
    Change-Id: Id11dd9ea78e5e522a6083d6a799e801cac81fd5b
    Reviewed-on: https://gerrit.libreoffice.org/59331
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Jenkins

diff --git a/cui/source/tabpages/tppattern.cxx b/cui/source/tabpages/tppattern.cxx
index 7d864da0326f..a696204da30e 100644
--- a/cui/source/tabpages/tppattern.cxx
+++ b/cui/source/tabpages/tppattern.cxx
@@ -29,6 +29,7 @@
 #include <svx/colorbox.hxx>
 #include <svx/dialmgr.hxx>
 #include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapTools.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/weld.hxx>
 #include <svx/dialogs.hrc>
@@ -74,7 +75,7 @@ public:
     {
         if (!pBmpArray)
             return BitmapEx();
-        return createHistorical8x8FromArray(*pBmpArray, aPixelColor, aBackgroundColor);
+        return vcl::bitmap::createHistorical8x8FromArray(*pBmpArray, aPixelColor, aBackgroundColor);
     }
 
     void SetBmpArray( std::array<sal_uInt8,64> const & pPixel ) { pBmpArray = &pPixel; }
@@ -296,7 +297,7 @@ IMPL_LINK_NOARG(SvxPatternTabPage, ChangePatternHdl_Impl, ValueSet*, void)
     {
         BitmapColor aBack;
         BitmapColor aFront;
-        bool bIs8x8(isHistorical8x8(pGraphicObject->GetGraphic().GetBitmapEx(), aBack, aFront));
+        bool bIs8x8(vcl::bitmap::isHistorical8x8(pGraphicObject->GetGraphic().GetBitmapEx(), aBack, aFront));
 
         m_pLbColor->SetNoSelection();
         m_pLbBackgroundColor->SetNoSelection();
diff --git a/include/svx/xbtmpit.hxx b/include/svx/xbtmpit.hxx
index 2f8e5f1181ee..218985c077d6 100644
--- a/include/svx/xbtmpit.hxx
+++ b/include/svx/xbtmpit.hxx
@@ -29,12 +29,6 @@ class SdrModel;
 class BitmapColor;
 
 
-// helper to construct historical 8x8 bitmaps with two colors
-
-BitmapEx SVX_DLLPUBLIC createHistorical8x8FromArray(std::array<sal_uInt8,64> const & pArray, Color aColorPix, Color aColorBack);
-bool SVX_DLLPUBLIC isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront);
-
-
 // class XFillBitmapItem
 
 class SVX_DLLPUBLIC XFillBitmapItem : public NameOrIndex
diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx
index 2064cb2d01dc..75eb6ed53077 100644
--- a/include/vcl/BitmapTools.hxx
+++ b/include/vcl/BitmapTools.hxx
@@ -23,6 +23,7 @@
 #include <basegfx/range/b2drectangle.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <o3tl/safeint.hxx>
+#include <array>
 
 namespace vcl {
 namespace bitmap {
@@ -113,6 +114,11 @@ VCL_DLLPUBLIC void CanvasCairoExtractBitmapData( BitmapEx const & rBmpEx, Bitmap
 
 VCL_DLLPUBLIC css::uno::Sequence< sal_Int8 > CanvasExtractBitmapData(BitmapEx const & rBitmapEx, const css::geometry::IntegerRectangle2D& rect);
 
+// helper to construct historical 8x8 bitmaps with two colors
+
+BitmapEx VCL_DLLPUBLIC createHistorical8x8FromArray(std::array<sal_uInt8,64> const & pArray, Color aColorPix, Color aColorBack);
+bool VCL_DLLPUBLIC isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront);
+
 }} // end vcl::bitmap
 
 #endif // INCLUDED_VCL_BITMAP_TOOLS_HXX
diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx
index 6f757f1ec62b..659a572ba369 100644
--- a/svx/source/dialog/dlgctrl.cxx
+++ b/svx/source/dialog/dlgctrl.cxx
@@ -46,6 +46,7 @@
 #include <svx/sdr/contact/objectcontactofobjlistpainter.hxx>
 #include <svx/sdr/contact/displayinfo.hxx>
 #include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapTools.hxx>
 #include <svx/xbtmpit.hxx>
 
 #define OUTPUT_DRAWMODE_COLOR       (DrawModeFlags::Default)
@@ -1442,7 +1443,7 @@ void SvxPixelCtl::SetXBitmap(const BitmapEx& rBitmapEx)
     BitmapColor aBack;
     BitmapColor aFront;
 
-    if (isHistorical8x8(rBitmapEx, aBack, aFront))
+    if (vcl::bitmap::isHistorical8x8(rBitmapEx, aBack, aFront))
     {
         Bitmap aBitmap(rBitmapEx.GetBitmap());
         Bitmap::ScopedReadAccess pRead(aBitmap);
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index 2e9269857935..262870a8ad8b 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -144,65 +144,6 @@ XFillBitmapItem::XFillBitmapItem(const XFillBitmapItem& rItem)
 {
 }
 
-BitmapEx createHistorical8x8FromArray(std::array<sal_uInt8,64> const & pArray, Color aColorPix, Color aColorBack)
-{
-    vcl::bitmap::RawBitmap aBitmap(Size(8, 8), 24);
-
-    for(sal_uInt16 a(0); a < 8; a++)
-    {
-        for(sal_uInt16 b(0); b < 8; b++)
-        {
-            if(pArray[(a * 8) + b])
-            {
-                aBitmap.SetPixel(a, b, aColorBack);
-            }
-            else
-            {
-                aBitmap.SetPixel(a, b, aColorPix);
-            }
-        }
-    }
-
-    return vcl::bitmap::CreateFromData(std::move(aBitmap));
-}
-
-bool isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront)
-{
-    bool bRet(false);
-
-    if(!rBitmapEx.IsTransparent())
-    {
-        Bitmap aBitmap(rBitmapEx.GetBitmap());
-
-        if(8 == aBitmap.GetSizePixel().Width() && 8 == aBitmap.GetSizePixel().Height())
-        {
-            if(2 == aBitmap.GetColorCount())
-            {
-                BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
-
-                if(pRead)
-                {
-                    if(pRead->HasPalette() && 2 == pRead->GetPaletteEntryCount())
-                    {
-                        const BitmapPalette& rPalette = pRead->GetPalette();
-
-                        // #i123564# background and foreground were exchanged; of course
-                        // rPalette[0] is the background color
-                        o_rFront = rPalette[1];
-                        o_rBack = rPalette[0];
-
-                        bRet = true;
-                    }
-
-                    Bitmap::ReleaseAccess(pRead);
-                }
-            }
-        }
-    }
-
-    return bRet;
-}
-
 XFillBitmapItem::XFillBitmapItem(const GraphicObject& rGraphicObject)
     : NameOrIndex(XATTR_FILLBITMAP, -1)
     , maGraphicObject(rGraphicObject)
@@ -224,7 +165,7 @@ bool XFillBitmapItem::operator==(const SfxPoolItem& rItem) const
 bool XFillBitmapItem::isPattern() const
 {
     BitmapColor aBack, aFront;
-    return isHistorical8x8(GetGraphicObject().GetGraphic().GetBitmapEx(), aBack, aFront);
+    return vcl::bitmap::isHistorical8x8(GetGraphicObject().GetGraphic().GetBitmapEx(), aBack, aFront);
 }
 
 sal_uInt16 XFillBitmapItem::GetVersion(sal_uInt16 /*nFileFormatVersion*/) const
diff --git a/svx/source/xoutdev/xtabptrn.cxx b/svx/source/xoutdev/xtabptrn.cxx
index 853fd24a819e..d207bb15de4c 100644
--- a/svx/source/xoutdev/xtabptrn.cxx
+++ b/svx/source/xoutdev/xtabptrn.cxx
@@ -29,6 +29,7 @@
 #include <svx/xbtmpit.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/svapp.hxx>
+#include <vcl/BitmapTools.hxx>
 
 #include <o3tl/make_unique.hxx>
 
@@ -56,28 +57,28 @@ bool XPatternList::Create()
 
     // white/white bitmap
     aStr.append(" 1");
-    aBitmap = createHistorical8x8FromArray(aArray, COL_WHITE, COL_WHITE);
+    aBitmap = vcl::bitmap::createHistorical8x8FromArray(aArray, COL_WHITE, COL_WHITE);
     Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString()));
 
     // black/white bitmap
     aArray[ 0] = 1; aArray[ 9] = 1; aArray[18] = 1; aArray[27] = 1;
     aArray[36] = 1; aArray[45] = 1; aArray[54] = 1; aArray[63] = 1;
     aStr[nLen] = '2';
-    aBitmap = createHistorical8x8FromArray(aArray, COL_BLACK, COL_WHITE);
+    aBitmap = vcl::bitmap::createHistorical8x8FromArray(aArray, COL_BLACK, COL_WHITE);
     Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString()));
 
     // lightred/white bitmap
     aArray[ 7] = 1; aArray[14] = 1; aArray[21] = 1; aArray[28] = 1;
     aArray[35] = 1; aArray[42] = 1; aArray[49] = 1; aArray[56] = 1;
     aStr[nLen] = '3';
-    aBitmap = createHistorical8x8FromArray(aArray, COL_LIGHTRED, COL_WHITE);
+    aBitmap = vcl::bitmap::createHistorical8x8FromArray(aArray, COL_LIGHTRED, COL_WHITE);
     Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString()));
 
     // lightblue/white bitmap
     aArray[24] = 1; aArray[25] = 1; aArray[26] = 1;
     aArray[29] = 1; aArray[30] = 1; aArray[31] = 1;
     aStr[nLen] = '4';
-    aBitmap = createHistorical8x8FromArray(aArray, COL_LIGHTBLUE, COL_WHITE);
+    aBitmap = vcl::bitmap::createHistorical8x8FromArray(aArray, COL_LIGHTBLUE, COL_WHITE);
     Insert(o3tl::make_unique<XBitmapEntry>(Graphic(aBitmap), aStr.toString()));
 
     return true;
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index 4f13511a5fab..707b4c6b27b4 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -994,6 +994,71 @@ void CanvasCairoExtractBitmapData( BitmapEx const & aBmpEx, Bitmap & aBitmap, un
         return aRes;
     }
 
+    BitmapEx createHistorical8x8FromArray(std::array<sal_uInt8,64> const & pArray, Color aColorPix, Color aColorBack)
+    {
+        BitmapPalette aPalette(2);
+
+        aPalette[0] = BitmapColor(aColorBack);
+        aPalette[1] = BitmapColor(aColorPix);
+
+        Bitmap aBitmap(Size(8, 8), 1, &aPalette);
+        BitmapWriteAccess* pContent(aBitmap.AcquireWriteAccess());
+
+        for(sal_uInt16 a(0); a < 8; a++)
+        {
+            for(sal_uInt16 b(0); b < 8; b++)
+            {
+                if(pArray[(a * 8) + b])
+                {
+                    pContent->SetPixelIndex(a, b, 1);
+                }
+                else
+                {
+                    pContent->SetPixelIndex(a, b, 0);
+                }
+            }
+        }
+
+        return BitmapEx(aBitmap);
+    }
+
+    bool isHistorical8x8(const BitmapEx& rBitmapEx, BitmapColor& o_rBack, BitmapColor& o_rFront)
+    {
+        bool bRet(false);
+
+        if(!rBitmapEx.IsTransparent())
+        {
+            Bitmap aBitmap(rBitmapEx.GetBitmap());
+
+            if(8 == aBitmap.GetSizePixel().Width() && 8 == aBitmap.GetSizePixel().Height())
+            {
+                if(2 == aBitmap.GetColorCount())
+                {
+                    BitmapReadAccess* pRead = aBitmap.AcquireReadAccess();
+
+                    if(pRead)
+                    {
+                        if(pRead->HasPalette() && 2 == pRead->GetPaletteEntryCount())
+                        {
+                            const BitmapPalette& rPalette = pRead->GetPalette();
+
+                            // #i123564# background and foreground were exchanged; of course
+                            // rPalette[0] is the background color
+                            o_rFront = rPalette[1];
+                            o_rBack = rPalette[0];
+
+                            bRet = true;
+                        }
+
+                        Bitmap::ReleaseAccess(pRead);
+                    }
+                }
+            }
+        }
+
+        return bRet;
+    }
+
 }} // end vcl::bitmap
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit f05f4e042ca6ac8ae7f1d1e8e6bfb4cbba17a044
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sun Aug 19 08:53:29 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Aug 21 21:06:17 2018 +0200

    loplugin:useuniqueptr in SvpSalInstance
    
    Change-Id: I8cab3c63ba4dcd08488d0fb34d689692d5cf97f9
    Reviewed-on: https://gerrit.libreoffice.org/59347
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/headless/svpdata.cxx b/vcl/headless/svpdata.cxx
index ce72305f85d9..9ca2c72fc6fa 100644
--- a/vcl/headless/svpdata.cxx
+++ b/vcl/headless/svpdata.cxx
@@ -9,6 +9,7 @@
 
 #include <unx/gendata.hxx>
 #include <headless/svpinst.hxx>
+#include <o3tl/make_unique.hxx>
 
 class SvpSalData : public GenericUnixSalData
 {
@@ -21,7 +22,7 @@ public:
 // plugin factory function
 SalInstance* svp_create_SalInstance()
 {
-    SvpSalInstance* pInstance = new SvpSalInstance( new SvpSalYieldMutex() );
+    SvpSalInstance* pInstance = new SvpSalInstance( o3tl::make_unique<SvpSalYieldMutex>() );
     new SvpSalData( pInstance );
     return pInstance;
 }
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index 5e0ec4c80b50..5cfd6247d897 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -63,8 +63,8 @@ static void atfork_child()
 
 #endif
 
-SvpSalInstance::SvpSalInstance( SalYieldMutex *pMutex )
-    : SalGenericInstance( pMutex )
+SvpSalInstance::SvpSalInstance( std::unique_ptr<SalYieldMutex> pMutex )
+    : SalGenericInstance( std::move(pMutex) )
 {
     m_aTimeout.tv_sec       = 0;
     m_aTimeout.tv_usec      = 0;
diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx
index 9c03662f7b8f..7c2b5efce593 100644
--- a/vcl/inc/headless/svpinst.hxx
+++ b/vcl/inc/headless/svpinst.hxx
@@ -112,7 +112,7 @@ class VCL_DLLPUBLIC SvpSalInstance : public SalGenericInstance, public SalUserEv
 public:
     static SvpSalInstance*  s_pDefaultInstance;
 
-    SvpSalInstance( SalYieldMutex *pMutex );
+    SvpSalInstance( std::unique_ptr<SalYieldMutex> pMutex );
     virtual ~SvpSalInstance() override;
 
     void                    CloseWakeupPipe(bool log);
diff --git a/vcl/inc/qt5/Qt5Instance.hxx b/vcl/inc/qt5/Qt5Instance.hxx
index a6d365a7d421..e68e55e8a5ef 100644
--- a/vcl/inc/qt5/Qt5Instance.hxx
+++ b/vcl/inc/qt5/Qt5Instance.hxx
@@ -54,7 +54,7 @@ Q_SIGNALS:
     bool ImplYieldSignal(bool bWait, bool bHandleAllCurrentEvents);
 
 public:
-    explicit Qt5Instance(SalYieldMutex* pMutex, bool bUseCairo = false);
+    explicit Qt5Instance(std::unique_ptr<SalYieldMutex> pMutex, bool bUseCairo = false);
     virtual ~Qt5Instance() override;
 
     virtual SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) override;
diff --git a/vcl/inc/unx/geninst.h b/vcl/inc/unx/geninst.h
index a1c5959f3b69..e7ed0efb2498 100644
--- a/vcl/inc/unx/geninst.h
+++ b/vcl/inc/unx/geninst.h
@@ -47,8 +47,8 @@ protected:
     std::unique_ptr<SalYieldMutex> mpSalYieldMutex;
 
 public:
-    SalGenericInstance( SalYieldMutex* pMutex )
-        : mbPrinterInit( false ), mpSalYieldMutex( pMutex ) {}
+    SalGenericInstance( std::unique_ptr<SalYieldMutex> pMutex )
+        : mbPrinterInit( false ), mpSalYieldMutex( std::move(pMutex) ) {}
     virtual ~SalGenericInstance() override;
 
     // Yield mutex
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index f9369f7add62..ae433e93c0cd 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -184,7 +184,7 @@ class GtkInstance : public X11SalInstance
     typedef X11SalInstance Superclass_t;
 #endif
 public:
-            GtkInstance( SalYieldMutex* pMutex );
+            GtkInstance( std::unique_ptr<SalYieldMutex> pMutex );
     virtual ~GtkInstance() override;
     void    EnsureInit();
     virtual void AfterAppInit() override;
diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h
index 34fe4f17657e..627754470447 100644
--- a/vcl/inc/unx/salinst.h
+++ b/vcl/inc/unx/salinst.h
@@ -47,7 +47,7 @@ protected:
     virtual SalX11Display* CreateDisplay() const;
 
 public:
-    explicit X11SalInstance(SalYieldMutex* pMutex);
+    explicit X11SalInstance(std::unique_ptr<SalYieldMutex> pMutex);
     virtual ~X11SalInstance() override;
 
     virtual SalFrame*           CreateChildFrame( SystemParentData* pParent, SalFrameStyleFlags nStyle ) override;
diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 3250abaf8f17..fefc1b1ec1d2 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -43,8 +43,8 @@
 
 #include <headless/svpbmp.hxx>
 
-Qt5Instance::Qt5Instance(SalYieldMutex* pMutex, bool bUseCairo)
-    : SalGenericInstance(pMutex)
+Qt5Instance::Qt5Instance(std::unique_ptr<SalYieldMutex> pMutex, bool bUseCairo)
+    : SalGenericInstance(std::move(pMutex))
     , m_postUserEventId(-1)
     , m_bUseCairo(bUseCairo)
 {
@@ -287,7 +287,7 @@ VCLPLUG_QT5_PUBLIC SalInstance* create_SalInstance()
     QApplication::setQuitOnLastWindowClosed(false);
 
     static const bool bUseCairo = (nullptr != getenv("SAL_VCL_QT5_USE_CAIRO"));
-    Qt5Instance* pInstance = new Qt5Instance(new SalYieldMutex(), bUseCairo);
+    Qt5Instance* pInstance = new Qt5Instance(o3tl::make_unique<SalYieldMutex>(), bUseCairo);
 
     // initialize SalData
     new Qt5Data(pInstance);
diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx
index c2d6197c38c8..ec3dd01d7891 100644
--- a/vcl/unx/generic/app/salinst.cxx
+++ b/vcl/unx/generic/app/salinst.cxx
@@ -54,7 +54,7 @@ extern "C"
         if( ! ( pNoXInitThreads && *pNoXInitThreads ) )
             XInitThreads();
 
-        X11SalInstance* pInstance = new X11SalInstance( new SalYieldMutex() );
+        X11SalInstance* pInstance = new X11SalInstance( o3tl::make_unique<SalYieldMutex>() );
 
         // initialize SalData
         X11SalData *pSalData = new X11SalData( SAL_DATA_UNX, pInstance );
@@ -66,8 +66,8 @@ extern "C"
     }
 }
 
-X11SalInstance::X11SalInstance(SalYieldMutex* pMutex)
-    : SalGenericInstance(pMutex)
+X11SalInstance::X11SalInstance(std::unique_ptr<SalYieldMutex> pMutex)
+    : SalGenericInstance(std::move(pMutex))
     , mpXLib(nullptr)
 {
     ImplSVData* pSVData = ImplGetSVData();
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index a22529d0a8a6..3dbf61e06645 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -91,8 +91,6 @@ extern "C"
         }
 #endif
 
-        GtkYieldMutex *pYieldMutex;
-
         // init gdk thread protection
         bool const sup = g_thread_supported();
             // extracted from the 'if' to avoid Clang -Wunreachable-code
@@ -102,11 +100,11 @@ extern "C"
         gdk_threads_set_lock_functions (GdkThreadsEnter, GdkThreadsLeave);
         SAL_INFO("vcl.gtk", "Hooked gdk threads locks");
 
-        pYieldMutex = new GtkYieldMutex();
+        auto pYieldMutex = o3tl::make_unique<GtkYieldMutex>();
 
         gdk_threads_init();
 
-        GtkInstance* pInstance = new GtkInstance( pYieldMutex );
+        GtkInstance* pInstance = new GtkInstance( std::move(pYieldMutex) );
         SAL_INFO("vcl.gtk", "creating GtkInstance " << pInstance);
 
         // Create SalData, this does not leak
@@ -147,11 +145,11 @@ static VclInputFlags categorizeEvent(const GdkEvent *pEvent)
 }
 #endif
 
-GtkInstance::GtkInstance( SalYieldMutex* pMutex )
+GtkInstance::GtkInstance( std::unique_ptr<SalYieldMutex> pMutex )
 #if GTK_CHECK_VERSION(3,0,0)
-    : SvpSalInstance( pMutex )
+    : SvpSalInstance( std::move(pMutex) )
 #else
-    : X11SalInstance( pMutex )
+    : X11SalInstance( std::move(pMutex) )
 #endif
     , m_pTimer(nullptr)
     , bNeedsInit(true)
diff --git a/vcl/unx/kde4/KDESalInstance.cxx b/vcl/unx/kde4/KDESalInstance.cxx
index 3db356b06abe..4af2c7888cb6 100644
--- a/vcl/unx/kde4/KDESalInstance.cxx
+++ b/vcl/unx/kde4/KDESalInstance.cxx
@@ -31,8 +31,8 @@
 
 using namespace com::sun::star;
 
-KDESalInstance::KDESalInstance(SalYieldMutex* pMutex)
-    : X11SalInstance(pMutex)
+KDESalInstance::KDESalInstance(std::unique_ptr<SalYieldMutex> pMutex)
+    : X11SalInstance(std::move(pMutex))
 {
     ImplSVData* pSVData = ImplGetSVData();
     delete pSVData->maAppData.mpToolkitName;
diff --git a/vcl/unx/kde4/KDESalInstance.hxx b/vcl/unx/kde4/KDESalInstance.hxx
index 7b7417caaaf1..87328a88406e 100644
--- a/vcl/unx/kde4/KDESalInstance.hxx
+++ b/vcl/unx/kde4/KDESalInstance.hxx
@@ -30,7 +30,7 @@ protected:
     virtual SalX11Display* CreateDisplay() const override;
 
 public:
-    explicit KDESalInstance(SalYieldMutex* pMutex);
+    explicit KDESalInstance(std::unique_ptr<SalYieldMutex> pMutex);
     virtual SalFrame* CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) override;
 
     virtual bool hasNativeFileSelection() const override { return true; }
diff --git a/vcl/unx/kde4/main.cxx b/vcl/unx/kde4/main.cxx
index ce01db772fe6..9d192247679b 100644
--- a/vcl/unx/kde4/main.cxx
+++ b/vcl/unx/kde4/main.cxx
@@ -73,7 +73,7 @@ extern "C" {
         }
 #endif
 
-        KDESalInstance* pInstance = new KDESalInstance( new SalYieldMutex() );
+        KDESalInstance* pInstance = new KDESalInstance( o3tl::make_unique<SalYieldMutex>() );
         SAL_INFO( "vcl.kde4", "created KDESalInstance " << &pInstance );
 
         // initialize SalData


More information about the Libreoffice-commits mailing list