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

Stephan Bergmann sbergman at redhat.com
Mon Nov 27 22:37:23 UTC 2017


 vcl/inc/win/salvd.h   |   10 +++++++---
 vcl/win/gdi/salvd.cxx |    6 ++----
 2 files changed, 9 insertions(+), 7 deletions(-)

New commits:
commit 401a3d2336bf46b38235c498ff86ff675d0de759
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Nov 27 15:04:28 2017 +0100

    loplugin:useuniqueptr (clang-cl)
    
    Change-Id: Id9020bef2ce0fa9a7a70f48d27fb57735c6f57ca
    Reviewed-on: https://gerrit.libreoffice.org/45340
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    Tested-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/vcl/inc/win/salvd.h b/vcl/inc/win/salvd.h
index 1e40ed706324..f4825836036e 100644
--- a/vcl/inc/win/salvd.h
+++ b/vcl/inc/win/salvd.h
@@ -20,6 +20,10 @@
 #ifndef INCLUDED_VCL_INC_WIN_SALVD_H
 #define INCLUDED_VCL_INC_WIN_SALVD_H
 
+#include <sal/config.h>
+
+#include <memory>
+
 #include <salvd.hxx>
 
 class WinSalGraphics;
@@ -31,7 +35,7 @@ private:
     HDC                     mhLocalDC;              // HDC or 0 for Cache Device
     HBITMAP                 mhBmp;                  // Memory Bitmap
     HBITMAP                 mhDefBmp;               // Default Bitmap
-    WinSalGraphics*         mpGraphics;             // current VirDev graphics
+    std::unique_ptr<WinSalGraphics> mpGraphics;     // current VirDev graphics
     WinSalVirtualDevice*    mpNext;                 // next VirDev
     sal_uInt16              mnBitCount;             // BitCount (0 or 1)
     bool                    mbGraphics;             // is Graphics used
@@ -41,8 +45,8 @@ private:
 
 public:
     HDC getHDC() const { return mhLocalDC; }
-    WinSalGraphics* getGraphics() const { return mpGraphics; }
-    void setGraphics(WinSalGraphics* pVirGraphics) { mpGraphics = pVirGraphics; }
+    WinSalGraphics* getGraphics() const { return mpGraphics.get(); }
+    void setGraphics(WinSalGraphics* pVirGraphics) { mpGraphics.reset(pVirGraphics); }
     WinSalVirtualDevice* getNext() const { return mpNext; }
 
     WinSalVirtualDevice(HDC hDC = nullptr, HBITMAP hBMP = nullptr, sal_uInt16 nBitCount = 0, bool bForeignDC = false, long nWidth = 0, long nHeight = 0);
diff --git a/vcl/win/gdi/salvd.cxx b/vcl/win/gdi/salvd.cxx
index 615bf3ee2207..17b32862d52f 100644
--- a/vcl/win/gdi/salvd.cxx
+++ b/vcl/win/gdi/salvd.cxx
@@ -148,7 +148,6 @@ SalVirtualDevice* WinSalInstance::CreateVirtualDevice( SalGraphics* pSGraphics,
 WinSalVirtualDevice::WinSalVirtualDevice(HDC hDC, HBITMAP hBMP, sal_uInt16 nBitCount, bool bForeignDC, long nWidth, long nHeight)
     : mhLocalDC(hDC),          // HDC or 0 for Cache Device
       mhBmp(hBMP),             // Memory Bitmap
-      mpGraphics(nullptr),     // current VirDev graphics
       mnBitCount(nBitCount),   // BitCount (0 or 1)
       mbGraphics(false),       // is Graphics used
       mbForeignDC(bForeignDC), // uses a foreign DC instead of a bitmap
@@ -186,8 +185,7 @@ WinSalVirtualDevice::~WinSalVirtualDevice()
         DeleteDC( mpGraphics->getHDC() );
     if( mhBmp )
         DeleteBitmap( mhBmp );
-    delete mpGraphics;
-    mpGraphics = nullptr;
+    mpGraphics.reset();
 }
 
 SalGraphics* WinSalVirtualDevice::AcquireGraphics()
@@ -198,7 +196,7 @@ SalGraphics* WinSalVirtualDevice::AcquireGraphics()
     if ( mpGraphics )
         mbGraphics = true;
 
-    return mpGraphics;
+    return mpGraphics.get();
 }
 
 void WinSalVirtualDevice::ReleaseGraphics( SalGraphics* )


More information about the Libreoffice-commits mailing list