vcl/inc/win/scoped_gdi.hxx |    1 +
 vcl/win/gdi/gdiimpl.cxx    |   20 +++++++-------------
 2 files changed, 8 insertions(+), 13 deletions(-)

New commits:
commit 643edcb11d635e09042d82d191279b6b1c2f25a9
Author:     Dmitriy Shilin <ds...@fastmail.com>
AuthorDate: Mon Jan 7 01:10:27 2019 -0800
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Jan 18 16:39:03 2019 +0100

    tdf#107792 vcl/win: introduce ScopedHBITMAP
    
    Change-Id: I2af507d9b924644d3a0e8a4bf2e92ca4b8a9a1b4
    Reviewed-on: https://gerrit.libreoffice.org/65929
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/vcl/inc/win/scoped_gdi.hxx b/vcl/inc/win/scoped_gdi.hxx
index 34e0e60a33c4..0fb82112e68c 100644
--- a/vcl/inc/win/scoped_gdi.hxx
+++ b/vcl/inc/win/scoped_gdi.hxx
@@ -29,6 +29,7 @@ using ScopedHRGN = ScopedGDI<HRGN, DeleteRegion>;
 using ScopedHDC = ScopedGDI<HDC, DeleteDC>;
 using ScopedHPEN = ScopedGDI<HPEN, DeletePen>;
 using ScopedHFONT = ScopedGDI<HFONT, DeleteFont>;
+using ScopedHBITMAP = ScopedGDI<HBITMAP, DeleteBitmap>;
 
 template <typename ScopedH, auto SelectorFunc> class ScopedSelectedGDI
 {
diff --git a/vcl/win/gdi/gdiimpl.cxx b/vcl/win/gdi/gdiimpl.cxx
index e5013631d9ed..a9406729fa21 100644
--- a/vcl/win/gdi/gdiimpl.cxx
+++ b/vcl/win/gdi/gdiimpl.cxx
@@ -678,17 +678,18 @@ void WinSalGraphicsImpl::drawBitmap( const SalTwoRect& 
rPosAry,
     int         nDstWidth = static_cast<int>(aPosAry.mnDestWidth);
     int         nDstHeight = static_cast<int>(aPosAry.mnDestHeight);
     HDC         hDC = mrParent.getHDC();
-    HBITMAP     hMemBitmap = nullptr;
-    HBITMAP     hMaskBitmap = nullptr;
+
+    ScopedHBITMAP hMemBitmap;
+    ScopedHBITMAP hMaskBitmap;
 
     if( ( nDstWidth > CACHED_HDC_DEFEXT ) || ( nDstHeight > CACHED_HDC_DEFEXT 
) )
     {
-        hMemBitmap = CreateCompatibleBitmap( hDC, nDstWidth, nDstHeight );
-        hMaskBitmap = CreateCompatibleBitmap( hDC, nDstWidth, nDstHeight );
+        hMemBitmap.reset(CreateCompatibleBitmap(hDC, nDstWidth, nDstHeight));
+        hMaskBitmap.reset(CreateCompatibleBitmap(hDC, nDstWidth, nDstHeight));
     }
 
-    HDC hMemDC = ImplGetCachedDC( CACHED_HDC_1, hMemBitmap );
-    HDC hMaskDC = ImplGetCachedDC( CACHED_HDC_2, hMaskBitmap );
+    HDC hMemDC = ImplGetCachedDC( CACHED_HDC_1, hMemBitmap.get() );
+    HDC hMaskDC = ImplGetCachedDC( CACHED_HDC_2, hMaskBitmap.get() );
 
     aPosAry.mnDestX = aPosAry.mnDestY = 0;
     BitBlt( hMemDC, 0, 0, nDstWidth, nDstHeight, hDC, nDstX, nDstY, SRCCOPY );
@@ -729,13 +730,6 @@ void WinSalGraphicsImpl::drawBitmap( const SalTwoRect& 
rPosAry,
 
     ImplReleaseCachedDC( CACHED_HDC_1 );
     ImplReleaseCachedDC( CACHED_HDC_2 );
-
-    // hMemBitmap != 0 ==> hMaskBitmap != 0
-    if( hMemBitmap )
-    {
-        DeleteObject( hMemBitmap );
-        DeleteObject( hMaskBitmap );
-    }
 }
 
 bool WinSalGraphicsImpl::drawAlphaRect( long nX, long nY, long nWidth,
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to