[Libreoffice-commits] core.git: vcl/win
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Wed Feb 24 18:21:49 UTC 2021
vcl/win/gdi/salbmp.cxx | 33 +++++++++++----------------------
1 file changed, 11 insertions(+), 22 deletions(-)
New commits:
commit e9db00584d30411ae07cfe8aa9660ba3636cc39a
Author: Noel Grandin <noel at peralex.com>
AuthorDate: Wed Feb 24 10:11:38 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Feb 24 19:21:01 2021 +0100
use unique_ptr in WinSalBitmap
Change-Id: I8ca55870094443f7eb670df06de34ad0ed87ad8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111445
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/vcl/win/gdi/salbmp.cxx b/vcl/win/gdi/salbmp.cxx
index 2418c10a1770..2f427cc5e70d 100644
--- a/vcl/win/gdi/salbmp.cxx
+++ b/vcl/win/gdi/salbmp.cxx
@@ -237,14 +237,14 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
{
Gdiplus::Bitmap* pRetval(nullptr);
WinSalBitmap* pSalRGB = this;
- WinSalBitmap* pExtraWinSalRGB = nullptr;
+ std::unique_ptr<WinSalBitmap> pExtraWinSalRGB;
if(!pSalRGB->ImplGethDIB())
{
// we need DIB for success with AcquireBuffer, create a replacement WinSalBitmap
- pExtraWinSalRGB = new WinSalBitmap();
+ pExtraWinSalRGB.reset(new WinSalBitmap());
pExtraWinSalRGB->Create(*pSalRGB, pSalRGB->GetBitCount());
- pSalRGB = pExtraWinSalRGB;
+ pSalRGB = pExtraWinSalRGB.get();
}
BitmapBuffer* pRGB = pSalRGB->AcquireBuffer(BitmapAccessMode::Read);
@@ -313,11 +313,6 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap()
pSalRGB->ReleaseBuffer(pRGB, BitmapAccessMode::Read);
}
- if(pExtraWinSalRGB)
- {
- delete pExtraWinSalRGB;
- }
-
return pRetval;
}
@@ -325,14 +320,14 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
{
Gdiplus::Bitmap* pRetval(nullptr);
WinSalBitmap* pSalRGB = this;
- WinSalBitmap* pExtraWinSalRGB = nullptr;
+ std::unique_ptr<WinSalBitmap> pExtraWinSalRGB;
if(!pSalRGB->ImplGethDIB())
{
// we need DIB for success with AcquireBuffer, create a replacement WinSalBitmap
- pExtraWinSalRGB = new WinSalBitmap();
+ pExtraWinSalRGB.reset(new WinSalBitmap());
pExtraWinSalRGB->Create(*pSalRGB, pSalRGB->GetBitCount());
- pSalRGB = pExtraWinSalRGB;
+ pSalRGB = pExtraWinSalRGB.get();
}
BitmapBuffer* pRGB = pSalRGB->AcquireBuffer(BitmapAccessMode::Read);
@@ -352,14 +347,14 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
}
WinSalBitmap* pSalA = const_cast< WinSalBitmap* >(&rAlphaSource);
- WinSalBitmap* pExtraWinSalA = nullptr;
+ std::unique_ptr<WinSalBitmap> pExtraWinSalA;
if(!pSalA->ImplGethDIB())
{
// we need DIB for success with AcquireBuffer, create a replacement WinSalBitmap
- pExtraWinSalA = new WinSalBitmap();
+ pExtraWinSalA.reset(new WinSalBitmap());
pExtraWinSalA->Create(*pSalA, pSalA->GetBitCount());
- pSalA = pExtraWinSalA;
+ pSalA = pExtraWinSalA.get();
}
BitmapBuffer* pA = pSalA->AcquireBuffer(BitmapAccessMode::Read);
@@ -447,10 +442,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
pSalA->ReleaseBuffer(pA, BitmapAccessMode::Read);
}
- if(pExtraWinSalA)
- {
- delete pExtraWinSalA;
- }
+ pExtraWinSalA.reset();
if(pExtraRGB)
{
@@ -464,10 +456,7 @@ Gdiplus::Bitmap* WinSalBitmap::ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlph
pSalRGB->ReleaseBuffer(pRGB, BitmapAccessMode::Read);
}
- if(pExtraWinSalRGB)
- {
- delete pExtraWinSalRGB;
- }
+ pExtraWinSalRGB.reset();
return pRetval;
}
More information about the Libreoffice-commits
mailing list