[Libreoffice-commits] core.git: sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jan 11 07:41:53 UTC 2019


 sw/source/core/undo/unsect.cxx |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

New commits:
commit 9fd69aba34f9818ac760f5704e007b92679d65b1
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jan 10 16:36:08 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jan 11 08:41:26 2019 +0100

    use unique_ptr in SwUndoDelSection
    
    Change-Id: I2637872300c60f880e32b00f5f545f6145b563bf
    Reviewed-on: https://gerrit.libreoffice.org/66120
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx
index 1a40d6c5b424..d10680ab9f97 100644
--- a/sw/source/core/undo/unsect.cxx
+++ b/sw/source/core/undo/unsect.cxx
@@ -42,12 +42,12 @@
 #include <calc.hxx>
 #include <o3tl/make_unique.hxx>
 
-static SfxItemSet* lcl_GetAttrSet( const SwSection& rSect )
+static std::unique_ptr<SfxItemSet> lcl_GetAttrSet( const SwSection& rSect )
 {
     // save attributes of the format (columns, color, ...)
     // Content and Protect items are not interesting since they are already
     // stored in Section, thus delete them.
-    SfxItemSet* pAttr = nullptr;
+    std::unique_ptr<SfxItemSet> pAttr;
     if( rSect.GetFormat() )
     {
         sal_uInt16 nCnt = 1;
@@ -56,13 +56,12 @@ static SfxItemSet* lcl_GetAttrSet( const SwSection& rSect )
 
         if( nCnt < rSect.GetFormat()->GetAttrSet().Count() )
         {
-            pAttr = new SfxItemSet( rSect.GetFormat()->GetAttrSet() );
+            pAttr.reset(new SfxItemSet( rSect.GetFormat()->GetAttrSet() ));
             pAttr->ClearItem( RES_PROTECT );
             pAttr->ClearItem( RES_CNTNT );
             if( !pAttr->Count() )
             {
-                delete pAttr;
-                pAttr = nullptr;
+                pAttr.reset();
             }
         }
     }
@@ -424,7 +423,7 @@ void SwUndoUpdateSection::UndoImpl(::sw::UndoRedoContext & rContext)
     SwSection& rNdSect = pSectNd->GetSection();
     SwFormat* pFormat = rNdSect.GetFormat();
 
-    SfxItemSet* pCur = ::lcl_GetAttrSet( rNdSect );
+    std::unique_ptr<SfxItemSet> pCur = ::lcl_GetAttrSet( rNdSect );
     if (m_pAttrSet)
     {
         // The Content and Protect items must persist
@@ -445,7 +444,7 @@ void SwUndoUpdateSection::UndoImpl(::sw::UndoRedoContext & rContext)
         pFormat->ResetFormatAttr( RES_HEADER, RES_OPAQUE );
         pFormat->ResetFormatAttr( RES_SURROUND, RES_FRMATR_END-1 );
     }
-    m_pAttrSet.reset(pCur);
+    m_pAttrSet = std::move(pCur);
 
     if (!m_bOnlyAttrChanged)
     {


More information about the Libreoffice-commits mailing list