[Libreoffice-commits] core.git: include/sfx2 sfx2/source

Noel Grandin noel.grandin at collabora.co.uk
Sun Jan 28 06:32:41 UTC 2018


 include/sfx2/request.hxx        |    4 ++--
 sfx2/source/control/request.cxx |   21 ++++++++++-----------
 2 files changed, 12 insertions(+), 13 deletions(-)

New commits:
commit 8ff90e5d901772e0c92356bf7c6a90caaac7964e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jan 16 15:22:48 2018 +0200

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

diff --git a/include/sfx2/request.hxx b/include/sfx2/request.hxx
index 72d98071007f..eb6e1fb0832a 100644
--- a/include/sfx2/request.hxx
+++ b/include/sfx2/request.hxx
@@ -51,7 +51,7 @@ class SFX2_DLLPUBLIC SfxRequest: public SfxHint
 friend struct SfxRequest_Impl;
 
     sal_uInt16          nSlot;
-    SfxAllItemSet*      pArgs;
+    std::unique_ptr<SfxAllItemSet>        pArgs;
     std::unique_ptr< SfxRequest_Impl >    pImpl;
 
 public:
@@ -78,7 +78,7 @@ public:
     void                SetModifier( sal_uInt16 nModi );
     SAL_DLLPRIVATE void SetInternalArgs_Impl( const SfxAllItemSet& rArgs );
     SAL_DLLPRIVATE const SfxItemSet* GetInternalArgs_Impl() const;
-    const SfxItemSet*   GetArgs() const { return pArgs; }
+    const SfxItemSet*   GetArgs() const { return pArgs.get(); }
     void                SetArgs( const SfxAllItemSet& rArgs );
     void                AppendItem(const SfxPoolItem &);
     void                RemoveItem( sal_uInt16 nSlotId );
diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx
index d7e6e6af1346..086aa45ec38c 100644
--- a/sfx2/source/control/request.cxx
+++ b/sfx2/source/control/request.cxx
@@ -123,7 +123,7 @@ SfxRequest::~SfxRequest()
         pImpl->Record( uno::Sequence < beans::PropertyValue >() );
 
     // Clear object
-    delete pArgs;
+    pArgs.reset();
     if ( pImpl->pRetVal )
         DeleteItemOnIdle(pImpl->pRetVal);
 }
@@ -408,8 +408,7 @@ void SfxRequest::Record_Impl
 
 void SfxRequest::SetArgs( const SfxAllItemSet& rArgs )
 {
-    delete pArgs;
-    pArgs = new SfxAllItemSet(rArgs);
+    pArgs.reset(new SfxAllItemSet(rArgs));
     pImpl->SetPool( pArgs->GetPool() );
 }
 
@@ -417,7 +416,7 @@ void SfxRequest::SetArgs( const SfxAllItemSet& rArgs )
 void SfxRequest::AppendItem(const SfxPoolItem &rItem)
 {
     if(!pArgs)
-        pArgs = new SfxAllItemSet(*pImpl->pPool);
+        pArgs.reset( new SfxAllItemSet(*pImpl->pPool) );
     pArgs->Put(rItem, rItem.Which());
 }
 
@@ -428,7 +427,7 @@ void SfxRequest::RemoveItem( sal_uInt16 nID )
     {
         pArgs->ClearItem(nID);
         if ( !pArgs->Count() )
-            DELETEZ(pArgs);
+            pArgs.reset();
     }
 }
 
@@ -480,7 +479,7 @@ void SfxRequest::Done
     // Keep items if possible, so they can be queried by StarDraw.
     if ( !pArgs )
     {
-        pArgs = new SfxAllItemSet( rSet );
+        pArgs.reset( new SfxAllItemSet( rSet ) );
         pImpl->SetPool( pArgs->GetPool() );
     }
     else
@@ -500,15 +499,15 @@ void SfxRequest::Done
 void SfxRequest::Done( bool bRelease )
 //  [<SfxRequest::Done(SfxItemSet&)>]
 {
-    Done_Impl( pArgs );
+    Done_Impl( pArgs.get() );
     if( bRelease )
-        DELETEZ( pArgs );
+        pArgs.reset();
 }
 
 
 void SfxRequest::ForgetAllArgs()
 {
-    DELETEZ( pArgs );
+    pArgs.reset();
     pImpl->pInternalArgs.reset();
 }
 
@@ -530,7 +529,7 @@ void SfxRequest::Cancel()
 {
     pImpl->bCancelled = true;
     pImpl->SetPool( nullptr );
-    DELETEZ( pArgs );
+    pArgs.reset();
 }
 
 
@@ -757,7 +756,7 @@ bool SfxRequest::AllowsRecording() const
 
 void SfxRequest::ReleaseArgs()
 {
-    DELETEZ( pArgs );
+    pArgs.reset();
     pImpl->pInternalArgs.reset();
 }
 


More information about the Libreoffice-commits mailing list