[Libreoffice-commits] core.git: vcl/quartz

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Sep 20 13:43:23 UTC 2018


 vcl/quartz/salbmp.cxx |   26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

New commits:
commit be30b7616cef6efa607eba00f52c8192759f7099
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Sep 15 21:49:40 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Sep 20 15:42:59 2018 +0200

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

diff --git a/vcl/quartz/salbmp.cxx b/vcl/quartz/salbmp.cxx
index b46a7f174168..94c02fd92aee 100644
--- a/vcl/quartz/salbmp.cxx
+++ b/vcl/quartz/salbmp.cxx
@@ -348,7 +348,7 @@ namespace {
 class ImplPixelFormat
 {
 public:
-    static ImplPixelFormat* GetFormat( sal_uInt16 nBits, const BitmapPalette& rPalette );
+    static std::unique_ptr<ImplPixelFormat> GetFormat( sal_uInt16 nBits, const BitmapPalette& rPalette );
 
     virtual void StartLine( sal_uInt8* pLine ) = 0;
     virtual void SkipPixel( sal_uInt32 nPixel ) = 0;
@@ -572,16 +572,16 @@ public:
         }
 };
 
-ImplPixelFormat* ImplPixelFormat::GetFormat( sal_uInt16 nBits, const BitmapPalette& rPalette )
+std::unique_ptr<ImplPixelFormat> ImplPixelFormat::GetFormat( sal_uInt16 nBits, const BitmapPalette& rPalette )
 {
     switch( nBits )
     {
-    case 1: return new ImplPixelFormat1( rPalette );
-    case 4: return new ImplPixelFormat4( rPalette );
-    case 8: return new ImplPixelFormat8( rPalette );
-    case 16: return new ImplPixelFormat16;
-    case 24: return new ImplPixelFormat24;
-    case 32: return new ImplPixelFormat32;
+    case 1: return o3tl::make_unique<ImplPixelFormat1>( rPalette );
+    case 4: return o3tl::make_unique<ImplPixelFormat4>( rPalette );
+    case 8: return o3tl::make_unique<ImplPixelFormat8>( rPalette );
+    case 16: return o3tl::make_unique<ImplPixelFormat16>();
+    case 24: return o3tl::make_unique<ImplPixelFormat24>();
+    case 32: return o3tl::make_unique<ImplPixelFormat32>();
     default:
         assert(false);
         return nullptr;
@@ -635,8 +635,8 @@ void QuartzSalBitmap::ConvertBitmapData( sal_uInt32 nWidth, sal_uInt32 nHeight,
     {
         // TODO: this implementation is for clarity, not for speed
 
-        ImplPixelFormat* pD = ImplPixelFormat::GetFormat( nDestBits, rDestPalette );
-        ImplPixelFormat* pS = ImplPixelFormat::GetFormat( nSrcBits, rSrcPalette );
+        std::unique_ptr<ImplPixelFormat> pD = ImplPixelFormat::GetFormat( nDestBits, rDestPalette );
+        std::unique_ptr<ImplPixelFormat> pS = ImplPixelFormat::GetFormat( nSrcBits, rSrcPalette );
 
         if( pD && pS )
         {
@@ -655,8 +655,6 @@ void QuartzSalBitmap::ConvertBitmapData( sal_uInt32 nWidth, sal_uInt32 nHeight,
                 pDestData += nDestBytesPerRow;
             }
         }
-        delete pS;
-        delete pD;
     }
 }
 
@@ -940,7 +938,7 @@ CGImageRef QuartzSalBitmap::CreateColorMask( int nX, int nY, int nWidth,
         std::unique_ptr<sal_uInt32[]> pMaskBuffer(new (std::nothrow) sal_uInt32[ nHeight * nDestBytesPerRow / 4] );
         sal_uInt32* pDest = pMaskBuffer.get();
 
-        ImplPixelFormat* pSourcePixels = ImplPixelFormat::GetFormat( mnBits, maPalette );
+        std::unique_ptr<ImplPixelFormat> pSourcePixels = ImplPixelFormat::GetFormat( mnBits, maPalette );
 
         if( pMaskBuffer && pSourcePixels )
         {
@@ -972,8 +970,6 @@ CGImageRef QuartzSalBitmap::CreateColorMask( int nX, int nY, int nWidth,
             SAL_INFO("vcl.cg", "CGImageCreate(" << nWidth << "x" << nHeight << "x8) = " << xMask );
             CFRelease(xDataProvider);
         }
-
-        delete pSourcePixels;
     }
     return xMask;
 }


More information about the Libreoffice-commits mailing list