[Libreoffice-commits] core.git: sc/inc sc/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Jun 21 08:30:21 UTC 2018


 sc/inc/chgtrack.hxx              |    9 +++------
 sc/source/core/tool/chgtrack.cxx |   11 +++++------
 2 files changed, 8 insertions(+), 12 deletions(-)

New commits:
commit f46f871f3170eb0d5a6522b7425c2390b601df5a
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jun 20 16:57:03 2018 +0200

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

diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index d5b157184b1c..a23744c53a08 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -523,6 +523,7 @@ public:
 class ScChangeActionMove : public ScChangeAction
 {
     friend class ScChangeTrack;
+    friend struct std::default_delete<ScChangeActionMove>; // for std::unique_ptr
     friend class ScChangeActionDel;
 
     ScBigRange          aFromRange;
@@ -870,7 +871,7 @@ class ScChangeTrack : public utl::ConfigurationListener
     ScChangeAction*     pLast;
     ScChangeActionContent*  pFirstGeneratedDelContent;
     std::unique_ptr<ScChangeActionContent*[]> ppContentSlots;
-    ScChangeActionMove*     pLastCutMove;
+    std::unique_ptr<ScChangeActionMove> pLastCutMove;
     ScChangeActionLinkEntry*    pLinkInsertCol;
     ScChangeActionLinkEntry*    pLinkInsertRow;
     ScChangeActionLinkEntry*    pLinkInsertTab;
@@ -1084,11 +1085,7 @@ public:
     void ResetLastCut()
     {
         nStartLastCut = nEndLastCut = 0;
-        if ( pLastCutMove )
-        {
-            delete pLastCutMove;
-            pLastCutMove = nullptr;
-        }
+        pLastCutMove.reset();
     }
     bool HasLastCut() const
     {
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 1acf76bf91dc..29fffe7561e8 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -2152,7 +2152,7 @@ void ScChangeTrack::DtorClear()
     {
         delete itChangeAction->second;
     }
-    delete pLastCutMove;
+    pLastCutMove.reset();
     ClearMsgQueue();
 }
 
@@ -2719,7 +2719,7 @@ void ScChangeTrack::AppendContentRange( const ScRange& rRange,
     if ( eClipMode == SC_CACM_CUT )
     {
         ResetLastCut();
-        pLastCutMove = new ScChangeActionMove( rRange, rRange, this );
+        pLastCutMove.reset(new ScChangeActionMove( rRange, rRange, this ));
         SetLastCutMoveRange( rRange, pRefDoc );
     }
     SCCOL nCol1;
@@ -2767,8 +2767,7 @@ void ScChangeTrack::AppendContentRange( const ScRange& rRange,
         LookUpContents( aRange, pRefDoc, 0, 0, 0 );
         pLastCutMove->SetStartLastCut( nStartLastCut );
         pLastCutMove->SetEndLastCut( nEndLastCut );
-        Append( pLastCutMove );
-        pLastCutMove = nullptr;
+        Append( pLastCutMove.release() );
         ResetLastCut();
         SetInPasteCut( false );
     }
@@ -3197,7 +3196,7 @@ void ScChangeTrack::Undo( sal_uLong nStartAction, sal_uLong nEndAction, bool bMe
                     ResetLastCut();
                     nStartLastCut = nStart;
                     nEndLastCut = nEnd;
-                    pLastCutMove = pMove;
+                    pLastCutMove.reset(pMove);
                     SetLastCutMoveRange(
                         pMove->GetFromRange().MakeRange(), pDoc );
                 }
@@ -3673,7 +3672,7 @@ void ScChangeTrack::UpdateReference( ScChangeAction** ppFirstAction,
     else if ( eActType == SC_CAT_MOVE )
     {
         ScChangeActionMove* pActMove = static_cast<ScChangeActionMove*>(pAct);
-        bool bLastCutMove = ( pActMove == pLastCutMove );
+        bool bLastCutMove = ( pActMove == pLastCutMove.get() );
         const ScBigRange& rTo = pActMove->GetBigRange();
         const ScBigRange& rFrom = pActMove->GetFromRange();
         if ( !bUndo )


More information about the Libreoffice-commits mailing list