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

Noel Grandin noel.grandin at collabora.co.uk
Thu Jun 14 09:50:26 UTC 2018


 include/vcl/bitmap.hxx                   |    3 ++-
 vcl/headless/svpgdi.cxx                  |    5 ++---
 vcl/headless/svpinst.cxx                 |    6 +++---
 vcl/inc/headless/svpgdi.hxx              |    2 +-
 vcl/inc/headless/svpinst.hxx             |    2 +-
 vcl/inc/openglgdiimpl.hxx                |    2 +-
 vcl/inc/osx/salinst.h                    |    2 +-
 vcl/inc/quartz/salgdi.h                  |    2 +-
 vcl/inc/salgdi.hxx                       |    4 ++--
 vcl/inc/salgdiimpl.hxx                   |    2 +-
 vcl/inc/salinst.hxx                      |    2 +-
 vcl/inc/unx/genpspgraphics.h             |    2 +-
 vcl/inc/unx/gtk/gtkinst.hxx              |    2 +-
 vcl/inc/unx/salgdi.h                     |    2 +-
 vcl/inc/unx/salinst.h                    |    2 +-
 vcl/inc/win/salgdi.h                     |    2 +-
 vcl/inc/win/salinst.h                    |    2 +-
 vcl/opengl/gdiimpl.cxx                   |    5 ++---
 vcl/osx/salinst.cxx                      |    4 ++--
 vcl/qt5/Qt5Graphics_GDI.cxx              |    4 ++--
 vcl/quartz/salgdicommon.cxx              |    8 +++-----
 vcl/source/bitmap/bitmap.cxx             |    6 +++---
 vcl/source/gdi/bitmapex.cxx              |    8 ++------
 vcl/source/gdi/salgdilayout.cxx          |    2 +-
 vcl/source/outdev/bitmap.cxx             |    5 ++---
 vcl/unx/generic/gdi/gdiimpl.cxx          |    6 +++---
 vcl/unx/generic/gdi/gdiimpl.hxx          |    2 +-
 vcl/unx/generic/gdi/salbmp.cxx           |    6 +++---
 vcl/unx/generic/gdi/salgdi2.cxx          |    2 +-
 vcl/unx/generic/print/genpspgraphics.cxx |    2 +-
 vcl/unx/gtk/gtkinst.cxx                  |    2 +-
 vcl/win/app/salinst.cxx                  |    6 +++---
 vcl/win/gdi/gdiimpl.cxx                  |    9 ++++-----
 vcl/win/gdi/gdiimpl.hxx                  |    2 +-
 vcl/win/gdi/salgdi2.cxx                  |    2 +-
 35 files changed, 58 insertions(+), 67 deletions(-)

New commits:
commit 8447d31e529985ef7fc71933f0e55685530f9fc9
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Fri Jun 8 12:29:09 2018 +0200

    return SalBitmap using std::shared_ptr
    
    since we hold it like that in Bitmap anyway
    
    Change-Id: I6264dfaaae6210cb008df5db8a421fc80c508f5b
    Reviewed-on: https://gerrit.libreoffice.org/55458
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index aa330fde9877..b304baa5af01 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -28,6 +28,7 @@
 #include <vcl/region.hxx>
 #include <vcl/scopedbitmapaccess.hxx>
 #include <o3tl/typed_flags_set.hxx>
+#include <memory>
 
 class Color;
 
@@ -124,7 +125,7 @@ public:
                             Bitmap();
                             Bitmap( const Bitmap& rBitmap );
                             Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalette* pPal = nullptr );
-    explicit                Bitmap( SalBitmap* pSalBitmap );
+    explicit                Bitmap( std::shared_ptr<SalBitmap> const & xSalBitmap );
     virtual                 ~Bitmap();
 
     Bitmap&                 operator=( const Bitmap& rBitmap );
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 4b5050420e7a..9163d8cf8133 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -1309,9 +1309,9 @@ void SvpSalGraphics::drawMask( const SalTwoRect& rTR,
     releaseCairoContext(cr, false, extents);
 }
 
-SalBitmap* SvpSalGraphics::getBitmap( long nX, long nY, long nWidth, long nHeight )
+std::shared_ptr<SalBitmap> SvpSalGraphics::getBitmap( long nX, long nY, long nWidth, long nHeight )
 {
-    SvpSalBitmap* pBitmap = new SvpSalBitmap();
+    std::shared_ptr<SvpSalBitmap> pBitmap = std::make_shared<SvpSalBitmap>();
     BitmapPalette aPal;
     if (GetBitCount() == 1)
     {
@@ -1323,7 +1323,6 @@ SalBitmap* SvpSalGraphics::getBitmap( long nX, long nY, long nWidth, long nHeigh
     if (!pBitmap->Create(Size(nWidth, nHeight), GetBitCount(), aPal))
     {
         SAL_WARN("vcl.gdi", "SvpSalGraphics::getBitmap, cannot create bitmap");
-        delete pBitmap;
         return nullptr;
     }
 
diff --git a/vcl/headless/svpinst.cxx b/vcl/headless/svpinst.cxx
index ad265e335265..3b43c46aae36 100644
--- a/vcl/headless/svpinst.cxx
+++ b/vcl/headless/svpinst.cxx
@@ -260,12 +260,12 @@ SalSystem* SvpSalInstance::CreateSalSystem()
     return new SvpSalSystem();
 }
 
-SalBitmap* SvpSalInstance::CreateSalBitmap()
+std::shared_ptr<SalBitmap> SvpSalInstance::CreateSalBitmap()
 {
 #ifdef IOS
-    return new QuartzSalBitmap();
+    return std::make_shared<QuartzSalBitmap>();
 #else
-    return new SvpSalBitmap();
+    return std::make_shared<SvpSalBitmap>();
 #endif
 }
 
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index c77e5dae4612..860eacec7cbf 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -232,7 +232,7 @@ public:
     virtual void            drawMask( const SalTwoRect& rPosAry,
                                       const SalBitmap& rSalBitmap,
                                       Color nMaskColor ) override;
-    virtual SalBitmap*      getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
+    virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
     virtual Color           getPixel( long nX, long nY ) override;
     virtual void            invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) override;
     virtual void            invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags ) override;
diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx
index a56aa408f601..810374c03802 100644
--- a/vcl/inc/headless/svpinst.hxx
+++ b/vcl/inc/headless/svpinst.hxx
@@ -164,7 +164,7 @@ public:
     // SalSystem
     virtual SalSystem*      CreateSalSystem() override;
     // SalBitmap
-    virtual SalBitmap*      CreateSalBitmap() override;
+    virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
 
     // wait next event and dispatch
     // must returned by UserEvent (SalFrame::PostEvent)
diff --git a/vcl/inc/openglgdiimpl.hxx b/vcl/inc/openglgdiimpl.hxx
index 251d176946d7..af2f7045a2b3 100644
--- a/vcl/inc/openglgdiimpl.hxx
+++ b/vcl/inc/openglgdiimpl.hxx
@@ -308,7 +308,7 @@ public:
                 const SalBitmap& rSalBitmap,
                 Color nMaskColor ) override;
 
-    virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
+    virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
 
     virtual Color getPixel( long nX, long nY ) override;
 
diff --git a/vcl/inc/osx/salinst.h b/vcl/inc/osx/salinst.h
index fa15a5cb7bca..13261df0d25a 100644
--- a/vcl/inc/osx/salinst.h
+++ b/vcl/inc/osx/salinst.h
@@ -112,7 +112,7 @@ public:
     virtual OUString        GetDefaultPrinter() override;
     virtual SalTimer*       CreateSalTimer() override;
     virtual SalSystem*      CreateSalSystem() override;
-    virtual SalBitmap*      CreateSalBitmap() override;
+    virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
     virtual comphelper::SolarMutex* GetYieldMutex() override;
     virtual sal_uInt32      ReleaseYieldMutexAll() override;
     virtual void            AcquireYieldMutex( sal_uInt32 nCount = 1 ) override;
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 325179e3d19a..a05ac07be7fb 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -252,7 +252,7 @@ public:
                                       const SalBitmap& rSalBitmap,
                                       Color nMaskColor ) override;
 
-    virtual SalBitmap*      getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
+    virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
     virtual Color           getPixel( long nX, long nY ) override;
 
     // invert --> ClipRegion (only Windows or VirDevs)
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index ceae6fd6160c..cacbfc71336b 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -306,7 +306,7 @@ public:
                                     Color nMaskColor,
                                     const OutputDevice *pOutDev );
 
-    SalBitmap*                  GetBitmap(
+    std::shared_ptr<SalBitmap>  GetBitmap(
                                     long nX, long nY,
                                     long nWidth, long nHeight,
                                     const OutputDevice *pOutDev );
@@ -508,7 +508,7 @@ protected:
                                     const SalBitmap& rSalBitmap,
                                     Color nMaskColor ) = 0;
 
-    virtual SalBitmap*          getBitmap( long nX, long nY, long nWidth, long nHeight ) = 0;
+    virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) = 0;
 
     virtual Color               getPixel( long nX, long nY ) = 0;
 
diff --git a/vcl/inc/salgdiimpl.hxx b/vcl/inc/salgdiimpl.hxx
index 89c6f4dba61d..3fb3a0bfd7f9 100644
--- a/vcl/inc/salgdiimpl.hxx
+++ b/vcl/inc/salgdiimpl.hxx
@@ -149,7 +149,7 @@ public:
                 const SalBitmap& rSalBitmap,
                 Color nMaskColor ) = 0;
 
-    virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight ) = 0;
+    virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) = 0;
 
     virtual Color getPixel( long nX, long nY ) = 0;
 
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index fa4fa92d3289..912ce9ac98f0 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -132,7 +132,7 @@ public:
     // SalSystem
     virtual SalSystem*      CreateSalSystem() = 0;
     // SalBitmap
-    virtual SalBitmap*      CreateSalBitmap() = 0;
+    virtual std::shared_ptr<SalBitmap> CreateSalBitmap() = 0;
 
     // YieldMutex
     virtual comphelper::SolarMutex*
diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index 2f95f3fdb676..a4a9885d8cb7 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -163,7 +163,7 @@ public:
     virtual void            drawMask( const SalTwoRect& rPosAry,
                                       const SalBitmap& rSalBitmap,
                                       Color nMaskColor ) override;
-    virtual SalBitmap*      getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
+    virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
     virtual Color           getPixel( long nX, long nY ) override;
     virtual void            invert( long nX, long nY, long nWidth, long nHeight,
                                     SalInvert nFlags ) override;
diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx
index 5f8534ae262f..f9369f7add62 100644
--- a/vcl/inc/unx/gtk/gtkinst.hxx
+++ b/vcl/inc/unx/gtk/gtkinst.hxx
@@ -207,7 +207,7 @@ public:
                                                      long &nDX, long &nDY,
                                                      DeviceFormat eFormat,
                                                      const SystemGraphicsData* = nullptr ) override;
-    virtual SalBitmap*          CreateSalBitmap() override;
+    virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
 
     virtual bool                DoYield(bool bWait, bool bHandleAllCurrentEvents) override;
     virtual bool                AnyInput( VclInputFlags nType ) override;
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index bc09b3e2be3a..9b656ac30223 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -217,7 +217,7 @@ public:
                                         const SalBitmap& rSalBitmap,
                                         Color nMaskColor ) override;
 
-    virtual SalBitmap*              getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
+    virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
     virtual Color                   getPixel( long nX, long nY ) override;
     virtual void                    invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ) override;
     virtual void                    invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags ) override;
diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h
index d61995f14d23..34fe4f17657e 100644
--- a/vcl/inc/unx/salinst.h
+++ b/vcl/inc/unx/salinst.h
@@ -71,7 +71,7 @@ public:
     virtual SalTimer*           CreateSalTimer() override;
     virtual std::unique_ptr<SalI18NImeStatus> CreateI18NImeStatus() override;
     virtual SalSystem*          CreateSalSystem() override;
-    virtual SalBitmap*          CreateSalBitmap() override;
+    virtual std::shared_ptr<SalBitmap>  CreateSalBitmap() override;
     virtual std::unique_ptr<SalSession> CreateSalSession() override;
     virtual OpenGLContext*      CreateOpenGLContext() override;
 
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 5f6dbe21836e..6b2e464bb0a1 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -251,7 +251,7 @@ protected:
                                   const SalBitmap& rSalBitmap,
                                   Color nMaskColor ) override;
 
-    virtual SalBitmap*  getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
+    virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
     virtual Color       getPixel( long nX, long nY ) override;
 
     // invert --> ClipRegion (only Windows or VirDevs)
diff --git a/vcl/inc/win/salinst.h b/vcl/inc/win/salinst.h
index f0df23433d10..cea4aff964bc 100644
--- a/vcl/inc/win/salinst.h
+++ b/vcl/inc/win/salinst.h
@@ -64,7 +64,7 @@ public:
     virtual OUString            GetDefaultPrinter() override;
     virtual SalTimer*           CreateSalTimer() override;
     virtual SalSystem*          CreateSalSystem() override;
-    virtual SalBitmap*          CreateSalBitmap() override;
+    virtual std::shared_ptr<SalBitmap> CreateSalBitmap() override;
     virtual comphelper::SolarMutex* GetYieldMutex() override;
     virtual sal_uInt32          ReleaseYieldMutexAll() override;
     virtual void                AcquireYieldMutex( sal_uInt32 nCount = 1 ) override;
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 6858a2adbae7..8deae07a3b77 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -1722,20 +1722,19 @@ void OpenGLSalGraphicsImpl::drawMask(
     PostBatchDraw();
 }
 
-SalBitmap* OpenGLSalGraphicsImpl::getBitmap( long nX, long nY, long nWidth, long nHeight )
+std::shared_ptr<SalBitmap> OpenGLSalGraphicsImpl::getBitmap( long nX, long nY, long nWidth, long nHeight )
 {
     FlushDeferredDrawing();
 
     OpenGLZone aZone;
 
-    OpenGLSalBitmap* pBitmap = new OpenGLSalBitmap;
+    std::shared_ptr<OpenGLSalBitmap> pBitmap(std::make_shared<OpenGLSalBitmap>());
     VCL_GL_INFO( "::getBitmap " << nX << "," << nY <<
               " " << nWidth << "x" << nHeight );
     //TODO really needed?
     PreDraw();
     if( !pBitmap->Create( maOffscreenTex, nX, nY, nWidth, nHeight ) )
     {
-        delete pBitmap;
         pBitmap = nullptr;
     }
     PostDraw();
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index 03d3f7a2663f..972a7fafcd76 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -960,9 +960,9 @@ SalSystem* AquaSalInstance::CreateSalSystem()
     return new AquaSalSystem();
 }
 
-SalBitmap* AquaSalInstance::CreateSalBitmap()
+std::shared_ptr<SalBitmap> AquaSalInstance::CreateSalBitmap()
 {
-    return new QuartzSalBitmap();
+    return std::make_shared<QuartzSalBitmap>();
 }
 
 OUString AquaSalInstance::getOSVersion()
diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx
index 43e54b8b1385..b58f18e4b59b 100644
--- a/vcl/qt5/Qt5Graphics_GDI.cxx
+++ b/vcl/qt5/Qt5Graphics_GDI.cxx
@@ -435,9 +435,9 @@ void Qt5Graphics::drawMask(const SalTwoRect& rPosAry, const SalBitmap& /*rSalBit
     assert(rPosAry.mnSrcHeight == rPosAry.mnDestHeight);
 }
 
-SalBitmap* Qt5Graphics::getBitmap(long nX, long nY, long nWidth, long nHeight)
+std::shared_ptr<SalBitmap> Qt5Graphics::getBitmap(long nX, long nY, long nWidth, long nHeight)
 {
-    return new Qt5Bitmap(m_pQImage->copy(nX, nY, nWidth, nHeight));
+    return std::make_shared<Qt5Bitmap>(m_pQImage->copy(nX, nY, nWidth, nHeight));
 }
 
 Color Qt5Graphics::getPixel(long nX, long nY) { return m_pQImage->pixel(nX, nY); }
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index e0dfdd721f5f..82dfe8932224 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -426,7 +426,7 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap
     }
     else
     {
-        SalBitmap* pBitmap = pSrc->getBitmap( rPosAry.mnSrcX, rPosAry.mnSrcY,
+        std::shared_ptr<SalBitmap> pBitmap = pSrc->getBitmap( rPosAry.mnSrcX, rPosAry.mnSrcY,
                                               rPosAry.mnSrcWidth, rPosAry.mnSrcHeight );
         if( pBitmap )
         {
@@ -434,7 +434,6 @@ void AquaSalGraphics::copyBits( const SalTwoRect& rPosAry, SalGraphics *pSrcGrap
             aPosAry.mnSrcX = 0;
             aPosAry.mnSrcY = 0;
             drawBitmap( aPosAry, *pBitmap );
-            delete pBitmap;
         }
     }
 }
@@ -1440,16 +1439,15 @@ sal_uInt16 AquaSalGraphics::GetBitCount() const
     return nBits;
 }
 
-SalBitmap* AquaSalGraphics::getBitmap( long  nX, long  nY, long  nDX, long  nDY )
+std::shared_ptr<SalBitmap> AquaSalGraphics::getBitmap( long  nX, long  nY, long  nDX, long  nDY )
 {
     SAL_WARN_IF( !mxLayer, "vcl.quartz", "AquaSalGraphics::getBitmap() with no layer this=" << this );
 
     ApplyXorContext();
 
-    QuartzSalBitmap* pBitmap = new QuartzSalBitmap;
+    std::shared_ptr<QuartzSalBitmap> pBitmap = std::make_shared<QuartzSalBitmap>();
     if( !pBitmap->Create( mxLayer, mnBitmapDepth, nX, nY, nDX, nDY, IsFlipped()) )
     {
-        delete pBitmap;
         pBitmap = nullptr;
     }
     return pBitmap;
diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx
index 23477b6e60ab..2de0da7b1a72 100644
--- a/vcl/source/bitmap/bitmap.cxx
+++ b/vcl/source/bitmap/bitmap.cxx
@@ -41,7 +41,7 @@ Bitmap::Bitmap(const Bitmap& rBitmap)
 {
 }
 
-Bitmap::Bitmap(SalBitmap* pSalBitmap)
+Bitmap::Bitmap(std::shared_ptr<SalBitmap> const & pSalBitmap)
     : mxSalBmp(pSalBitmap)
     , maPrefMapMode(MapMode(MapUnit::MapPixel))
     , maPrefSize(mxSalBmp->GetSize())
@@ -104,7 +104,7 @@ Bitmap::Bitmap( const Size& rSizePixel, sal_uInt16 nBitCount, const BitmapPalett
                 pRealPal = const_cast<BitmapPalette*>(pPal);
         }
 
-        mxSalBmp.reset(ImplGetSVData()->mpDefInst->CreateSalBitmap());
+        mxSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
         mxSalBmp->Create( rSizePixel, nBitCount, pRealPal ? *pRealPal : aPal );
     }
 }
@@ -311,7 +311,7 @@ void Bitmap::ImplMakeUnique()
     if (mxSalBmp && mxSalBmp.use_count() > 1)
     {
         std::shared_ptr<SalBitmap> xOldImpBmp = mxSalBmp;
-        mxSalBmp.reset(ImplGetSVData()->mpDefInst->CreateSalBitmap());
+        mxSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
         mxSalBmp->Create(*xOldImpBmp);
     }
 }
diff --git a/vcl/source/gdi/bitmapex.cxx b/vcl/source/gdi/bitmapex.cxx
index a369efe1ebf7..4f3ac4f0b5da 100644
--- a/vcl/source/gdi/bitmapex.cxx
+++ b/vcl/source/gdi/bitmapex.cxx
@@ -776,8 +776,8 @@ bool BitmapEx::Create( const css::uno::Reference< css::rendering::XBitmapCanvas
         }
     }
 
-    SalBitmap* pSalBmp = nullptr;
-    SalBitmap* pSalMask = nullptr;
+    std::shared_ptr<SalBitmap> pSalBmp;
+    std::shared_ptr<SalBitmap> pSalMask;
 
     pSalBmp = ImplGetSVData()->mpDefInst->CreateSalBitmap();
 
@@ -792,15 +792,11 @@ bool BitmapEx::Create( const css::uno::Reference< css::rendering::XBitmapCanvas
         }
         else
         {
-            delete pSalMask;
             *this = BitmapEx(Bitmap(pSalBmp));
             return true;
         }
     }
 
-    delete pSalBmp;
-    delete pSalMask;
-
     return false;
 }
 
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 49cc105d5d54..47b2f7590321 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -606,7 +606,7 @@ void SalGraphics::DrawMask( const SalTwoRect& rPosAry,
         drawMask( rPosAry, rSalBitmap, nMaskColor );
 }
 
-SalBitmap* SalGraphics::GetBitmap( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev )
+std::shared_ptr<SalBitmap> SalGraphics::GetBitmap( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev )
 {
     if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
         mirror( nX, nWidth, pOutDev );
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 4108bc6f2cf8..0ab77a8b578d 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -465,12 +465,11 @@ Bitmap OutputDevice::GetBitmap( const Point& rSrcPt, const Size& rSize ) const
 
             if ( !bClipped )
             {
-                SalBitmap* pSalBmp = mpGraphics->GetBitmap( nX, nY, nWidth, nHeight, this );
+                std::shared_ptr<SalBitmap> pSalBmp = mpGraphics->GetBitmap( nX, nY, nWidth, nHeight, this );
 
                 if( pSalBmp )
                 {
-                    std::shared_ptr<SalBitmap> xImpBmp(pSalBmp);
-                    aBmp.ImplSetSalBitmap(xImpBmp);
+                    aBmp.ImplSetSalBitmap(pSalBmp);
                 }
             }
         }
diff --git a/vcl/unx/generic/gdi/gdiimpl.cxx b/vcl/unx/generic/gdi/gdiimpl.cxx
index b815992e2d4d..1fd3d61be2b8 100644
--- a/vcl/unx/generic/gdi/gdiimpl.cxx
+++ b/vcl/unx/generic/gdi/gdiimpl.cxx
@@ -586,7 +586,7 @@ void X11SalGraphicsImpl::copyBits( const SalTwoRect& rPosAry,
         // #i60699# No chance to handle graphics exposures - we copy
         // to a temp bitmap first, into which no repaints are
         // technically possible.
-        std::unique_ptr<SalBitmap> xDDB(pSrcGraphics->getBitmap( rPosAry.mnSrcX,
+        std::shared_ptr<SalBitmap> xDDB(pSrcGraphics->getBitmap( rPosAry.mnSrcX,
                                                                    rPosAry.mnSrcY,
                                                                    rPosAry.mnSrcWidth,
                                                                    rPosAry.mnSrcHeight ));
@@ -1684,7 +1684,7 @@ Color X11SalGraphicsImpl::getPixel( long nX, long nY )
     return mrParent.GetColormap().GetColor( aXColor.pixel );
 }
 
-SalBitmap *X11SalGraphicsImpl::getBitmap( long nX, long nY, long nDX, long nDY )
+std::shared_ptr<SalBitmap> X11SalGraphicsImpl::getBitmap( long nX, long nY, long nDX, long nDY )
 {
     bool bFakeWindowBG = false;
 
@@ -1737,7 +1737,7 @@ SalBitmap *X11SalGraphicsImpl::getBitmap( long nX, long nY, long nDX, long nDY )
         }
     }
 
-    X11SalBitmap* pSalBitmap = new X11SalBitmap;
+    std::shared_ptr<X11SalBitmap> pSalBitmap = std::make_shared<X11SalBitmap>();
     sal_uInt16 nBitCount = GetBitCount();
 
     if( &mrParent.GetDisplay()->GetColormap( mrParent.m_nXScreen ) != &mrParent.GetColormap() )
diff --git a/vcl/unx/generic/gdi/gdiimpl.hxx b/vcl/unx/generic/gdi/gdiimpl.hxx
index 1b71c47a182b..156700fcac8a 100644
--- a/vcl/unx/generic/gdi/gdiimpl.hxx
+++ b/vcl/unx/generic/gdi/gdiimpl.hxx
@@ -206,7 +206,7 @@ public:
                 const SalBitmap& rSalBitmap,
                 Color nMaskColor ) override;
 
-    virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
+    virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
 
     virtual Color getPixel( long nX, long nY ) override;
 
diff --git a/vcl/unx/generic/gdi/salbmp.cxx b/vcl/unx/generic/gdi/salbmp.cxx
index d50c92feba90..a8b5f365a83b 100644
--- a/vcl/unx/generic/gdi/salbmp.cxx
+++ b/vcl/unx/generic/gdi/salbmp.cxx
@@ -52,12 +52,12 @@
 #include <memory>
 
 
-SalBitmap* X11SalInstance::CreateSalBitmap()
+std::shared_ptr<SalBitmap> X11SalInstance::CreateSalBitmap()
 {
     if (OpenGLHelper::isVCLOpenGLEnabled())
-        return new OpenGLSalBitmap();
+        return std::make_shared<OpenGLSalBitmap>();
     else
-        return new X11SalBitmap();
+        return std::make_shared<X11SalBitmap>();
 }
 
 ImplSalBitmapCache* X11SalBitmap::mpCache = nullptr;
diff --git a/vcl/unx/generic/gdi/salgdi2.cxx b/vcl/unx/generic/gdi/salgdi2.cxx
index 3903960bc4b8..33ab8498c3d6 100644
--- a/vcl/unx/generic/gdi/salgdi2.cxx
+++ b/vcl/unx/generic/gdi/salgdi2.cxx
@@ -233,7 +233,7 @@ void X11SalGraphics::drawMask( const SalTwoRect& rPosAry,
     mxImpl->drawMask( rPosAry, rSalBitmap, nMaskColor );
 }
 
-SalBitmap *X11SalGraphics::getBitmap( long nX, long nY, long nDX, long nDY )
+std::shared_ptr<SalBitmap> X11SalGraphics::getBitmap( long nX, long nY, long nDX, long nDY )
 {
     return mxImpl->getBitmap( nX, nY, nDX, nDY );
 }
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index a16bf100d466..4bcc0a227dd0 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -495,7 +495,7 @@ void GenPspGraphics::drawMask( const SalTwoRect&,
     OSL_FAIL("Error: PrinterGfx::DrawMask() not implemented");
 }
 
-SalBitmap* GenPspGraphics::getBitmap( long, long, long, long )
+std::shared_ptr<SalBitmap> GenPspGraphics::getBitmap( long, long, long, long )
 {
     SAL_INFO("vcl", "Warning: PrinterGfx::GetBitmap() not implemented");
     return nullptr;
diff --git a/vcl/unx/gtk/gtkinst.cxx b/vcl/unx/gtk/gtkinst.cxx
index 4cf31b82312a..20fc1a4e6a0a 100644
--- a/vcl/unx/gtk/gtkinst.cxx
+++ b/vcl/unx/gtk/gtkinst.cxx
@@ -345,7 +345,7 @@ std::unique_ptr<SalVirtualDevice> GtkInstance::CreateVirtualDevice( SalGraphics
 #endif
 }
 
-SalBitmap* GtkInstance::CreateSalBitmap()
+std::shared_ptr<SalBitmap> GtkInstance::CreateSalBitmap()
 {
     EnsureInit();
 #if GTK_CHECK_VERSION(3,0,0)
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 652e47636ca2..cfdc68b4ac43 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -986,12 +986,12 @@ SalTimer* WinSalInstance::CreateSalTimer()
     return new WinSalTimer();
 }
 
-SalBitmap* WinSalInstance::CreateSalBitmap()
+std::shared_ptr<SalBitmap> WinSalInstance::CreateSalBitmap()
 {
     if (OpenGLHelper::isVCLOpenGLEnabled())
-        return new OpenGLSalBitmap();
+        return std::make_shared<OpenGLSalBitmap>();
     else
-        return new WinSalBitmap();
+        return std::make_shared<WinSalBitmap>();
 }
 
 const OUString& SalGetDesktopEnvironment()
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index f18fbcf40779..5b7f225e7d96 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -851,11 +851,11 @@ void WinSalGraphicsImpl::drawMask( const SalTwoRect& rPosAry,
     DeleteBrush( hMaskBrush );
 }
 
-SalBitmap* WinSalGraphicsImpl::getBitmap( long nX, long nY, long nDX, long nDY )
+std::shared_ptr<SalBitmap> WinSalGraphicsImpl::getBitmap( long nX, long nY, long nDX, long nDY )
 {
     SAL_WARN_IF( mrParent.isPrinter(), "vcl", "No ::GetBitmap() from printer possible!" );
 
-    WinSalBitmap* pSalBitmap = nullptr;
+    std::shared_ptr<WinSalBitmap> pSalBitmap;
 
     nDX = labs( nDX );
     nDY = labs( nDY );
@@ -870,12 +870,11 @@ SalBitmap* WinSalGraphicsImpl::getBitmap( long nX, long nY, long nDX, long nDY )
 
     if( bRet )
     {
-        pSalBitmap = new WinSalBitmap;
+        pSalBitmap = std::make_shared<WinSalBitmap>();
 
         if( !pSalBitmap->Create( hBmpBitmap, FALSE, FALSE ) )
         {
-            delete pSalBitmap;
-            pSalBitmap = nullptr;
+            pSalBitmap.reset();
         }
     }
     else
diff --git a/vcl/win/gdi/gdiimpl.hxx b/vcl/win/gdi/gdiimpl.hxx
index f4810c1e1f3b..3bd39663aa9c 100644
--- a/vcl/win/gdi/gdiimpl.hxx
+++ b/vcl/win/gdi/gdiimpl.hxx
@@ -154,7 +154,7 @@ public:
                 const SalBitmap& rSalBitmap,
                 Color nMaskColor ) override;
 
-    virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
+    virtual std::shared_ptr<SalBitmap> getBitmap( long nX, long nY, long nWidth, long nHeight ) override;
 
     virtual Color getPixel( long nX, long nY ) override;
 
diff --git a/vcl/win/gdi/salgdi2.cxx b/vcl/win/gdi/salgdi2.cxx
index c34a215eb304..2e2d3469e8bd 100644
--- a/vcl/win/gdi/salgdi2.cxx
+++ b/vcl/win/gdi/salgdi2.cxx
@@ -215,7 +215,7 @@ void WinSalGraphics::drawMask( const SalTwoRect& rPosAry,
     mpImpl->drawMask( rPosAry, rSSalBitmap, nMaskColor );
 }
 
-SalBitmap* WinSalGraphics::getBitmap( long nX, long nY, long nDX, long nDY )
+std::shared_ptr<SalBitmap> WinSalGraphics::getBitmap( long nX, long nY, long nDX, long nDY )
 {
     return mpImpl->getBitmap( nX, nY, nDX, nDY );
 }


More information about the Libreoffice-commits mailing list