vcl/inc/win/salprn.h   |    2 +-
 vcl/win/gdi/salprn.cxx |   12 ++++--------
 2 files changed, 5 insertions(+), 9 deletions(-)

New commits:
commit d27187b158d7e3f92180b1f2ab79b048dc5318a5
Author:     Mark Hung <mark...@gmail.com>
AuthorDate: Mon Oct 11 10:26:56 2021 +0800
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Oct 12 08:34:28 2021 +0200

    vcl:use unique_ptr<SalWinGraphics> in WinSalPrinter
    
    to replace plain SalWinGraphics pointer, and get rid
    of delete.
    
    Change-Id: If06df98a8ebfdf5797bddfefa37647522b8e711b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123365
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/vcl/inc/win/salprn.h b/vcl/inc/win/salprn.h
index 43eaa520c23d..2d02aa5b0e54 100644
--- a/vcl/inc/win/salprn.h
+++ b/vcl/inc/win/salprn.h
@@ -78,7 +78,7 @@ public:
 class WinSalPrinter : public SalPrinter
 {
 public:
-    WinSalGraphics*         mpGraphics;             // current Printer graphics
+    std::unique_ptr<WinSalGraphics> mxGraphics;    // current Printer graphics
     WinSalInfoPrinter*      mpInfoPrinter;          // pointer to the 
compatible InfoPrinter
     WinSalPrinter*          mpNextPrinter;          // next printing printer
     HDC                     mhDC;                   // printer hdc
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 21e779eb6156..86e1e616a57f 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -1350,7 +1350,6 @@ static DEVMODEW const * ImplSalSetCopies( DEVMODEW const 
* pDevMode, sal_uInt32
 
 
 WinSalPrinter::WinSalPrinter() :
-    mpGraphics( nullptr ),
     mpInfoPrinter( nullptr ),
     mpNextPrinter( nullptr ),
     mhDC( nullptr ),
@@ -1374,7 +1373,6 @@ WinSalPrinter::~WinSalPrinter()
     HDC hDC = mhDC;
     if ( hDC )
     {
-        delete mpGraphics;
         DeleteDC( hDC );
     }
 
@@ -1531,8 +1529,7 @@ bool WinSalPrinter::EndJob()
     HDC hDC = mhDC;
     if (isValid())
     {
-        delete mpGraphics;
-        mpGraphics = nullptr;
+        mxGraphics.reset();
 
         // #i54419# Windows fax printer brings up a dialog in EndDoc
         // which text previously copied in soffice process can be
@@ -1587,14 +1584,13 @@ SalGraphics* WinSalPrinter::StartPage( ImplJobSetup* 
pSetupData, bool bNewJobDat
     SelectPen( hDC, hTempPen );
     SelectBrush( hDC, hTempBrush );
 
-    mpGraphics = ImplCreateSalPrnGraphics( hDC );
-    return mpGraphics;
+    mxGraphics.reset(ImplCreateSalPrnGraphics( hDC ));
+    return mxGraphics.get();
 }
 
 void WinSalPrinter::EndPage()
 {
-    delete mpGraphics;
-    mpGraphics = nullptr;
+    mxGraphics.reset();
 
     if (!isValid())
         return;

Reply via email to