[Libreoffice-commits] core.git: 2 commits - include/vcl vcl/source vcl/unx

Noel Grandin noel.grandin at collabora.co.uk
Wed Apr 25 07:31:35 UTC 2018


 include/vcl/scrbar.hxx                |    3 ++-
 vcl/source/control/scrbar.cxx         |    4 ++--
 vcl/unx/generic/printer/ppdparser.cxx |   20 ++++++++------------
 3 files changed, 12 insertions(+), 15 deletions(-)

New commits:
commit 18c32d5824618e3ac00c4755f380b2b033a96fc9
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Apr 23 09:06:41 2018 +0200

    loplugin:useuniqueptr in ScrollBar
    
    Change-Id: I827e997391834d10a617b7c5be8ceafc19e97219
    Reviewed-on: https://gerrit.libreoffice.org/53343
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/vcl/scrbar.hxx b/include/vcl/scrbar.hxx
index fdacb3ed1059..db4d2ee9273c 100644
--- a/include/vcl/scrbar.hxx
+++ b/include/vcl/scrbar.hxx
@@ -23,6 +23,7 @@
 #include <tools/solar.h>
 #include <vcl/dllapi.h>
 #include <vcl/ctrl.hxx>
+#include <memory>
 
 class AutoTimer;
 
@@ -47,7 +48,7 @@ private:
     tools::Rectangle       maPage2Rect;
     tools::Rectangle       maThumbRect;
     tools::Rectangle       maTrackRect;
-    ImplScrollBarData* mpData;
+    std::unique_ptr<ImplScrollBarData> mpData;
     long            mnStartPos;
     long            mnMouseOff;
     long            mnThumbPixRange;
diff --git a/vcl/source/control/scrbar.cxx b/vcl/source/control/scrbar.cxx
index f34201af2a03..4efc0c807061 100644
--- a/vcl/source/control/scrbar.cxx
+++ b/vcl/source/control/scrbar.cxx
@@ -115,7 +115,7 @@ ScrollBar::~ScrollBar()
 
 void ScrollBar::dispose()
 {
-    delete mpData; mpData = nullptr;
+    mpData.reset();
     Control::dispose();
 }
 
@@ -1137,7 +1137,7 @@ void ScrollBar::GetFocus()
 {
     if( !mpData )
     {
-        mpData = new ImplScrollBarData;
+        mpData.reset(new ImplScrollBarData);
         mpData->maTimer.SetInvokeHandler( LINK( this, ScrollBar, ImplAutoTimerHdl ) );
         mpData->maTimer.SetDebugName( "vcl::ScrollBar mpData->maTimer" );
         mpData->mbHide = false;
commit ef46d846fdedd9e94f7150afda810d12acce8c16
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Apr 23 15:19:49 2018 +0200

    loplugin:useuniqueptr in PPDDecompressStream
    
    Change-Id: Idad3c18c57e4ae4121505a0bd9761f8569685e33
    Reviewed-on: https://gerrit.libreoffice.org/53358
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx
index a6109af7f289..fc58bc3464b6 100644
--- a/vcl/unx/generic/printer/ppdparser.cxx
+++ b/vcl/unx/generic/printer/ppdparser.cxx
@@ -259,8 +259,8 @@ private:
     PPDDecompressStream(const PPDDecompressStream&) = delete;
     PPDDecompressStream& operator=(const PPDDecompressStream&) = delete;
 
-    SvFileStream*       mpFileStream;
-    SvMemoryStream*     mpMemStream;
+    std::unique_ptr<SvFileStream>   mpFileStream;
+    std::unique_ptr<SvMemoryStream> mpMemStream;
     OUString       maFileName;
 
 public:
@@ -291,7 +291,7 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
 {
     Close();
 
-    mpFileStream = new SvFileStream( i_rFile, StreamMode::READ );
+    mpFileStream.reset( new SvFileStream( i_rFile, StreamMode::READ ) );
     maFileName = mpFileStream->GetFileName();
 
     if( ! mpFileStream->IsOpen() )
@@ -309,7 +309,7 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
         && static_cast<unsigned char>(aLine[1]) == 0x8b /* check for gzip */ )
     {
         // so let's try to decompress the stream
-        mpMemStream = new SvMemoryStream( 4096, 4096 );
+        mpMemStream.reset( new SvMemoryStream( 4096, 4096 ) );
         ZCodec aCodec;
         aCodec.BeginCompression( ZCODEC_DEFAULT_COMPRESSION, false, true );
         long nComp = aCodec.Decompress( *mpFileStream, *mpMemStream );
@@ -317,15 +317,13 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
         if( nComp < 0 )
         {
             // decompression failed, must be an uncompressed stream after all
-            delete mpMemStream;
-            mpMemStream = nullptr;
+            mpMemStream.reset();
             mpFileStream->Seek( 0 );
         }
         else
         {
             // compression successful, can get rid of file stream
-            delete mpFileStream;
-            mpFileStream = nullptr;
+            mpFileStream.reset();
             mpMemStream->Seek( 0 );
         }
     }
@@ -333,10 +331,8 @@ void PPDDecompressStream::Open( const OUString& i_rFile )
 
 void PPDDecompressStream::Close()
 {
-    delete mpMemStream;
-    mpMemStream = nullptr;
-    delete mpFileStream;
-    mpFileStream = nullptr;
+    mpMemStream.reset();
+    mpFileStream.reset();
 }
 
 bool PPDDecompressStream::IsOpen() const


More information about the Libreoffice-commits mailing list