[Libreoffice-commits] core.git: vcl/inc vcl/win

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 24 18:22:23 UTC 2021


 vcl/inc/win/salbmp.h   |    4 ++--
 vcl/win/gdi/salbmp.cxx |   22 ++++++++++------------
 2 files changed, 12 insertions(+), 14 deletions(-)

New commits:
commit e7c723765c90b4a6d1918f6964d15f101b80a88e
Author:     Noel Grandin <noel at peralex.com>
AuthorDate: Wed Feb 24 10:15:36 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Feb 24 19:21:25 2021 +0100

    use unique_ptr in WinSalBitmap
    
    Change-Id: I3c536b766d35b3137d79739c232d0d5cff3652b2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111446
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/inc/win/salbmp.h b/vcl/inc/win/salbmp.h
index d6acd14e8c7d..80ddb38bfd9e 100644
--- a/vcl/inc/win/salbmp.h
+++ b/vcl/inc/win/salbmp.h
@@ -42,8 +42,8 @@ private:
 
     sal_uInt16          mnBitCount;
 
-    Gdiplus::Bitmap*    ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource);
-    Gdiplus::Bitmap*    ImplCreateGdiPlusBitmap();
+    std::unique_ptr<Gdiplus::Bitmap>    ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource);
+    std::unique_ptr<Gdiplus::Bitmap> ImplCreateGdiPlusBitmap();
 
 public:
 
diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx
index 2f427cc5e70d..b0dffd5394dd 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -214,12 +214,12 @@ std::shared_ptr< Gdiplus::Bitmap > WinSalBitmap::ImplGetGdiPlusBitmap(const WinS
 
         if(pAlphaSource)
         {
-            aRetval.reset(const_cast< WinSalBitmap* >(this)->ImplCreateGdiPlusBitmap(*pAlphaSource));
+            aRetval = const_cast< WinSalBitmap* >(this)->ImplCreateGdiPlusBitmap(*pAlphaSource);
             pAssociatedAlpha = pAlphaSource;
         }
         else
         {
-            aRetval.reset(const_cast< WinSalBitmap* >(this)->ImplCreateGdiPlusBitmap());
+            aRetval = const_cast< WinSalBitmap* >(this)->ImplCreateGdiPlusBitmap();
             pAssociatedAlpha = nullptr;
         }
 
@@ -233,9 +233,9 @@ std::shared_ptr< Gdiplus::Bitmap > WinSalBitmap::ImplGetGdiPlusBitmap(const WinS
     return aRetval;
 }
 
-Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
+std::unique_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap()
 {
-    Gdiplus::Bitmap* pRetval(nullptr);
+    std::unique_ptr<Gdiplus::Bitmap> pRetval;
     WinSalBitmap* pSalRGB = this;
     std::unique_ptr<WinSalBitmap> pExtraWinSalRGB;
 
@@ -271,7 +271,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
         const sal_uInt32 nW(pRGB->mnWidth);
         const sal_uInt32 nH(pRGB->mnHeight);
 
-        pRetval = new Gdiplus::Bitmap(nW, nH, PixelFormat24bppRGB);
+        pRetval.reset(new Gdiplus::Bitmap(nW, nH, PixelFormat24bppRGB));
 
         if ( pRetval->GetLastStatus() == Gdiplus::Ok )
         {
@@ -296,8 +296,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
         }
         else
         {
-            delete pRetval;
-            pRetval = nullptr;
+            pRetval.reset();
         }
     }
 
@@ -316,9 +315,9 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
     return pRetval;
 }
 
-Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource)
+std::unique_ptr<Gdiplus::Bitmap> WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource)
 {
-    Gdiplus::Bitmap* pRetval(nullptr);
+    std::unique_ptr<Gdiplus::Bitmap> pRetval;
     WinSalBitmap* pSalRGB = this;
     std::unique_ptr<WinSalBitmap> pExtraWinSalRGB;
 
@@ -389,7 +388,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
         const sal_uInt32 nW(pRGB->mnWidth);
         const sal_uInt32 nH(pRGB->mnHeight);
 
-        pRetval = new Gdiplus::Bitmap(nW, nH, PixelFormat32bppARGB);
+        pRetval.reset(new Gdiplus::Bitmap(nW, nH, PixelFormat32bppARGB));
 
         if ( pRetval->GetLastStatus() == Gdiplus::Ok ) // 2nd place to secure with new Gdiplus::Bitmap
         {
@@ -425,8 +424,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
         }
         else
         {
-            delete pRetval;
-            pRetval = nullptr;
+            pRetval.reset();
         }
     }
 


More information about the Libreoffice-commits mailing list