diff options
author | Noel Grandin <noel@peralex.com> | 2021-02-24 10:15:36 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-24 19:21:25 +0100 |
commit | e7c723765c90b4a6d1918f6964d15f101b80a88e (patch) | |
tree | 5b4dbe20666adad1f72af1e9d5d971f1de2655c4 | |
parent | e9db00584d30411ae07cfe8aa9660ba3636cc39a (diff) |
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@collabora.co.uk>
-rw-r--r-- | vcl/inc/win/salbmp.h | 4 | ||||
-rw-r--r-- | vcl/win/gdi/salbmp.cxx | 22 |
2 files changed, 12 insertions, 14 deletions
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(); } } |