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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 10 07:29:05 UTC 2019


 sw/inc/ndtxt.hxx                   |    4 ++--
 sw/source/core/doc/docedt.cxx      |   13 ++++++-------
 sw/source/core/doc/list.cxx        |   12 ++++++------
 sw/source/core/docnode/ndtbl.cxx   |    8 ++++----
 sw/source/core/fields/authfld.cxx  |    7 +++----
 sw/source/core/frmedt/fecopy.cxx   |    9 ++++-----
 sw/source/core/frmedt/fefly1.cxx   |   23 ++++++++++-------------
 sw/source/core/frmedt/feshview.cxx |    7 +++----
 sw/source/core/layout/flyincnt.cxx |    6 +++---
 sw/source/core/layout/ftnfrm.cxx   |    9 ++++-----
 sw/source/core/txtnode/ndtxt.cxx   |   19 +++++++------------
 11 files changed, 52 insertions(+), 65 deletions(-)

New commits:
commit a3f409262db9a9939d40e8f009f3e2396c78c020
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jan 9 16:13:21 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jan 10 08:28:49 2019 +0100

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

diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 4c0e6468fb9b..e10fd669eddc 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -91,8 +91,8 @@ class SW_DLLPUBLIC SwTextNode
        Therefore: never access directly! */
     std::unique_ptr<SwpHints> m_pSwpHints;
 
-    mutable SwNodeNum* mpNodeNum;  ///< Numbering for this paragraph.
-    mutable SwNodeNum* mpNodeNumRLHidden; ///< Numbering for this paragraph (hidden redlines)
+    mutable std::unique_ptr<SwNodeNum> mpNodeNum;  ///< Numbering for this paragraph.
+    mutable std::unique_ptr<SwNodeNum> mpNodeNumRLHidden; ///< Numbering for this paragraph (hidden redlines)
 
     OUString m_Text;
 
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 07a69d87b0e7..7a2a4cdf0ee1 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -200,8 +200,6 @@ SwTextNode *SwNodes::MakeTextNode( const SwNodeIndex & rWhere,
 
 SwTextNode::SwTextNode( const SwNodeIndex &rWhere, SwTextFormatColl *pTextColl, const SfxItemSet* pAutoAttr )
 :   SwContentNode( rWhere, SwNodeType::Text, pTextColl ),
-    mpNodeNum( nullptr ),
-    mpNodeNumRLHidden(nullptr),
     m_Text(),
     m_pParaIdleData_Impl(nullptr),
     m_bContainsHiddenChars(false),
@@ -3976,20 +3974,19 @@ const SwNodeNum* SwTextNode::GetNum(SwRootFrame const*const pLayout) const
 {
     // invariant: it's only in list in Hide mode if it's in list in normal mode
     assert(mpNodeNum || !mpNodeNumRLHidden);
-    return pLayout && pLayout->IsHideRedlines() ? mpNodeNumRLHidden : mpNodeNum;
+    return pLayout && pLayout->IsHideRedlines() ? mpNodeNumRLHidden.get() : mpNodeNum.get();
 }
 
 void SwTextNode::DoNum(std::function<void (SwNodeNum &)> const& rFunc)
 {
     // temp. clear because GetActualListLevel() may be called and the assert
     // there triggered during update, which is unhelpful
-    SwNodeNum * pBackup(mpNodeNumRLHidden);
-    mpNodeNumRLHidden = nullptr;
+    std::unique_ptr<SwNodeNum> pBackup = std::move(mpNodeNumRLHidden);
     assert(mpNodeNum);
     rFunc(*mpNodeNum);
     if (pBackup)
     {
-        mpNodeNumRLHidden = pBackup;
+        mpNodeNumRLHidden = std::move(pBackup);
         rFunc(*mpNodeNumRLHidden);
     }
 }
@@ -4289,7 +4286,7 @@ void SwTextNode::AddToList()
     if (pList && GetNodes().IsDocNodes()) // not for undo nodes
     {
         assert(!mpNodeNum);
-        mpNodeNum = new SwNodeNum(this, false);
+        mpNodeNum.reset(new SwNodeNum(this, false));
         pList->InsertListItem(*mpNodeNum, false, GetAttrListLevel());
         // iterate all frames & if there's one with hidden layout...
         SwIterator<SwTextFrame, SwTextNode, sw::IteratorMode::UnwrapMulti> iter(*this);
@@ -4320,7 +4317,7 @@ void SwTextNode::AddToListRLHidden()
     if (pList)
     {
         assert(!mpNodeNumRLHidden);
-        mpNodeNumRLHidden = new SwNodeNum(this, true);
+        mpNodeNumRLHidden.reset(new SwNodeNum(this, true));
         pList->InsertListItem(*mpNodeNumRLHidden, true, GetAttrListLevel());
     }
 }
@@ -4332,8 +4329,7 @@ void SwTextNode::RemoveFromList()
     if ( IsInList() )
     {
         SwList::RemoveListItem( *mpNodeNum );
-        delete mpNodeNum;
-        mpNodeNum = nullptr;
+        mpNodeNum.reset();
 
         SetWordCountDirty( true );
     }
@@ -4345,8 +4341,7 @@ void SwTextNode::RemoveFromListRLHidden()
     {
         assert(mpNodeNumRLHidden->GetParent() || !GetNodes().IsDocNodes());
         SwList::RemoveListItem(*mpNodeNumRLHidden);
-        delete mpNodeNumRLHidden;
-        mpNodeNumRLHidden = nullptr;
+        mpNodeNumRLHidden.reset();
 
         SetWordCountDirty( true );
     }
commit 6cd5d350db92b78f1d4b8a552e0b8972d48c16a0
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jan 9 15:20:06 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Jan 10 08:28:39 2019 +0100

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

diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 9fceec0533a6..542ff303216e 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -286,9 +286,9 @@ void SaveRedlEndPosForRestore::Restore()
 }
 
 /// Convert list of ranges of whichIds to a corresponding list of whichIds
-static std::vector<sal_uInt16> * lcl_RangesToVector(const sal_uInt16 * pRanges)
+static std::vector<sal_uInt16> lcl_RangesToVector(const sal_uInt16 * pRanges)
 {
-    std::vector<sal_uInt16> * pResult = new std::vector<sal_uInt16>;
+    std::vector<sal_uInt16> aResult;
 
     int i = 0;
     while (pRanges[i] != 0)
@@ -296,12 +296,12 @@ static std::vector<sal_uInt16> * lcl_RangesToVector(const sal_uInt16 * pRanges)
         OSL_ENSURE(pRanges[i+1] != 0, "malformed ranges");
 
         for (sal_uInt16 j = pRanges[i]; j < pRanges[i+1]; j++)
-            pResult->push_back(j);
+            aResult.push_back(j);
 
         i += 2;
     }
 
-    return pResult;
+    return aResult;
 }
 
 void sw_GetJoinFlags( SwPaM& rPam, bool& rJoinText, bool& rJoinPrev )
@@ -441,10 +441,9 @@ bool sw_JoinText( SwPaM& rPam, bool bJoinPrev )
                    first resetting all character attributes in first
                    paragraph (pTextNd).
                 */
-                std::vector<sal_uInt16> * pShorts =
+                std::vector<sal_uInt16> aShorts =
                     lcl_RangesToVector(aCharFormatSetRange);
-                pTextNd->ResetAttr(*pShorts);
-                delete pShorts;
+                pTextNd->ResetAttr(aShorts);
 
                 if( pDelNd->HasSwAttrSet() )
                 {
diff --git a/sw/source/core/doc/list.cxx b/sw/source/core/doc/list.cxx
index 6744dd7aa321..b1d055b22d99 100644
--- a/sw/source/core/doc/list.cxx
+++ b/sw/source/core/doc/list.cxx
@@ -72,8 +72,8 @@ class SwListImpl
             std::unique_ptr<SwNodeNum> pRootRLHidden;
             /// top-level SwNodes section
             std::unique_ptr<SwPaM> pSection;
-            tListTreeForRange(SwNodeNum *const p1, SwNodeNum *const p2, SwPaM *const p3)
-                : pRoot(p1), pRootRLHidden(p2), pSection(p3) {}
+            tListTreeForRange(std::unique_ptr<SwNodeNum> p1, std::unique_ptr<SwNodeNum> p2, std::unique_ptr<SwPaM> p3)
+                : pRoot(std::move(p1)), pRootRLHidden(std::move(p2)), pSection(std::move(p3)) {}
         };
         typedef std::vector<tListTreeForRange> tListTrees;
         tListTrees maListTrees;
@@ -97,10 +97,10 @@ SwListImpl::SwListImpl( const OUString& sListId,
     {
         SwPaM aPam( *pNode, *pNode->EndOfSectionNode() );
 
-        SwNodeNum* pNumberTreeRootNode = new SwNodeNum( &rDefaultListStyle );
-        SwNodeNum* pNumberTreeRootNodeRL = new SwNodeNum( &rDefaultListStyle );
-        SwPaM* pPam = new SwPaM( *(aPam.Start()), *(aPam.End()) );
-        maListTrees.emplace_back(pNumberTreeRootNode, pNumberTreeRootNodeRL, pPam);
+        maListTrees.emplace_back(
+            std::make_unique<SwNodeNum>( &rDefaultListStyle ),
+            std::make_unique<SwNodeNum>( &rDefaultListStyle ),
+            std::make_unique<SwPaM>( *(aPam.Start()), *(aPam.End()) ));
 
         pNode = pNode->EndOfSectionNode();
         if (pNode != &rNodes.GetEndOfContent())
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index e2fbc874aab3..47246bd18a69 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3454,19 +3454,19 @@ bool SwDoc::MergeTable( const SwPosition& rPos, bool bWithPrev, sal_uInt16 nMode
 
     // Both Tables are present; we can start
     SwUndoMergeTable* pUndo = nullptr;
-    SwHistory* pHistory = nullptr;
+    std::unique_ptr<SwHistory> pHistory;
     if (GetIDocumentUndoRedo().DoesUndo())
     {
         pUndo = new SwUndoMergeTable( *pTableNd, *pDelTableNd, bWithPrev, nMode );
         GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndo));
-        pHistory = new SwHistory;
+        pHistory.reset(new SwHistory);
     }
 
     // Adapt all "TableFormulas"
     SwTableFormulaUpdate aMsgHint( &pTableNd->GetTable() );
     aMsgHint.m_aData.pDelTable = &pDelTableNd->GetTable();
     aMsgHint.m_eFlags = TBL_MERGETBL;
-    aMsgHint.m_pHistory = pHistory;
+    aMsgHint.m_pHistory = pHistory.get();
     getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
 
     // The actual merge
@@ -3477,7 +3477,7 @@ bool SwDoc::MergeTable( const SwPosition& rPos, bool bWithPrev, sal_uInt16 nMode
     {
         if( pHistory->Count() )
             pUndo->SaveFormula( *pHistory );
-        delete pHistory;
+        pHistory.reset();
     }
     if( bRet )
     {
diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx
index 410d0bd22944..1f4a64b7ac2a 100644
--- a/sw/source/core/fields/authfld.cxx
+++ b/sw/source/core/fields/authfld.cxx
@@ -109,7 +109,7 @@ void    SwAuthorityFieldType::RemoveField(sal_IntPtr nHandle)
 sal_IntPtr SwAuthorityFieldType::AddField(const OUString& rFieldContents)
 {
     sal_IntPtr nRet = 0;
-    SwAuthEntry* pEntry = new SwAuthEntry;
+    std::unique_ptr<SwAuthEntry> pEntry(new SwAuthEntry);
     for( sal_Int32 i = 0; i < AUTH_FIELD_END; ++i )
         pEntry->SetAuthorField( static_cast<ToxAuthorityField>(i),
                         rFieldContents.getToken( i, TOX_STYLE_DELIMITER ));
@@ -118,7 +118,6 @@ sal_IntPtr SwAuthorityFieldType::AddField(const OUString& rFieldContents)
     {
         if (*rpTemp == *pEntry)
         {
-            delete pEntry;
             nRet = reinterpret_cast<sal_IntPtr>(static_cast<void*>(rpTemp.get()));
             rpTemp->AddRef();
             return nRet;
@@ -126,10 +125,10 @@ sal_IntPtr SwAuthorityFieldType::AddField(const OUString& rFieldContents)
     }
 
     //if it is a new Entry - insert
-    nRet = reinterpret_cast<sal_IntPtr>(static_cast<void*>(pEntry));
+    nRet = reinterpret_cast<sal_IntPtr>(static_cast<void*>(pEntry.get()));
     // FIXME: what is this ref-counting madness on a object owned by the container?
     pEntry->AddRef();
-    m_DataArr.push_back(std::unique_ptr<SwAuthEntry>(pEntry));
+    m_DataArr.push_back(std::move(pEntry));
     //re-generate positions of the fields
     DelSequenceArray();
     return nRet;
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index 2315d6e839c1..430871b0657b 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -585,20 +585,20 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
             aBoxes.empty() ? nullptr : aBoxes[0]->GetSttNd()->FindTableNode());
         if (nullptr != pTableNd)
         {
-            SwPosition* pDstPos = nullptr;
+            std::unique_ptr<SwPosition> pDstPos;
             if( this == pDestShell )
             {
                 // same shell? Then create new Cursor at the
                 // DocumentPosition passed
-                pDstPos = new SwPosition( *GetCursor()->GetPoint() );
+                pDstPos.reset(new SwPosition( *GetCursor()->GetPoint() ));
                 Point aPt( rInsPt );
-                GetLayout()->GetCursorOfst( pDstPos, aPt );
+                GetLayout()->GetCursorOfst( pDstPos.get(), aPt );
                 if( !pDstPos->nNode.GetNode().IsNoTextNode() )
                     bRet = true;
             }
             else if( !pDestShell->GetCursor()->GetNode().IsNoTextNode() )
             {
-                pDstPos = new SwPosition( *pDestShell->GetCursor()->GetPoint() );
+                pDstPos.reset(new SwPosition( *pDestShell->GetCursor()->GetPoint() ));
                 bRet = true;
             }
 
@@ -625,7 +625,6 @@ bool SwFEShell::Copy( SwFEShell* pDestShell, const Point& rSttPt,
                 if( this == pDestShell )
                     GetCursorDocPos() = rInsPt;
             }
-            delete pDstPos;
         }
     }
     else
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 9f9f12bec56a..8729c84d8646 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -590,15 +590,14 @@ Point SwFEShell::FindAnchorPos( const Point& rAbsPos, bool bMoveIt )
                     // re-created. Thus, delete all fly frames except the <this> before the
                     // anchor attribute is change and re-create them afterwards.
                     {
-                        SwHandleAnchorNodeChg* pHandleAnchorNodeChg( nullptr );
+                        std::unique_ptr<SwHandleAnchorNodeChg> pHandleAnchorNodeChg;
                         SwFlyFrameFormat* pFlyFrameFormat( dynamic_cast<SwFlyFrameFormat*>(&rFormat) );
                         if ( pFlyFrameFormat )
                         {
-                            pHandleAnchorNodeChg =
-                                new SwHandleAnchorNodeChg( *pFlyFrameFormat, aAnch );
+                            pHandleAnchorNodeChg.reset(
+                                new SwHandleAnchorNodeChg( *pFlyFrameFormat, aAnch ));
                         }
                         rFormat.GetDoc()->SetAttr( aAnch, rFormat );
-                        delete pHandleAnchorNodeChg;
                     }
                     // #i28701# - no call of method
                     // <CheckCharRectAndTopOfLine()> for to-character anchored
@@ -698,7 +697,7 @@ const SwFrameFormat *SwFEShell::NewFlyFrame( const SfxItemSet& rSet, bool bAnchV
     if( bMoveContent )
     {
         GetDoc()->GetIDocumentUndoRedo().StartUndo( SwUndoId::INSLAYFMT, nullptr );
-        SwFormatAnchor* pOldAnchor = nullptr;
+        std::unique_ptr<SwFormatAnchor> pOldAnchor;
         bool bHOriChgd = false, bVOriChgd = false;
         SwFormatVertOrient aOldV;
         SwFormatHoriOrient aOldH;
@@ -709,7 +708,7 @@ const SwFrameFormat *SwFEShell::NewFlyFrame( const SfxItemSet& rSet, bool bAnchV
             // everything was shifted. Then the position is valid!
             // JP 13.05.98: if necessary also convert the horizontal/vertical
             //              orientation, to prevent correction during re-anchoring
-            pOldAnchor = new SwFormatAnchor( rAnch );
+            pOldAnchor.reset(new SwFormatAnchor( rAnch ));
             const_cast<SfxItemSet&>(rSet).Put( SwFormatAnchor( RndStdIds::FLY_AT_PAGE, 1 ) );
 
             const SfxPoolItem* pItem;
@@ -779,7 +778,6 @@ const SwFrameFormat *SwFEShell::NewFlyFrame( const SfxItemSet& rSet, bool bAnchV
                 GetDoc()->SetFlyFrameAttr( *pRet, const_cast<SfxItemSet&>(rSet) );
                 GetDoc()->GetIDocumentUndoRedo().DoUndo(bDoesUndo);
             }
-            delete pOldAnchor;
         }
         GetDoc()->GetIDocumentUndoRedo().EndUndo( SwUndoId::INSLAYFMT, nullptr );
     }
@@ -1204,20 +1202,19 @@ void SwFEShell::SetFrameFormat( SwFrameFormat *pNewFormat, bool bKeepOrient, Poi
         SwFlyFrameFormat* pFlyFormat = pFly->GetFormat();
         const Point aPt( pFly->getFrameArea().Pos() );
 
-        SfxItemSet* pSet = nullptr;
+        std::unique_ptr<SfxItemSet> pSet;
         const SfxPoolItem* pItem;
         if( SfxItemState::SET == pNewFormat->GetItemState( RES_ANCHOR, false, &pItem ))
         {
-            pSet = new SfxItemSet( GetDoc()->GetAttrPool(), aFrameFormatSetRange );
+            pSet.reset(new SfxItemSet( GetDoc()->GetAttrPool(), aFrameFormatSetRange ));
             pSet->Put( *pItem );
             if( !sw_ChkAndSetNewAnchor( *pFly, *pSet ))
             {
-                delete pSet;
-                pSet = nullptr;
+                pSet.reset();
             }
         }
 
-        if( GetDoc()->SetFrameFormatToFly( *pFlyFormat, *pNewFormat, pSet, bKeepOrient ))
+        if( GetDoc()->SetFrameFormatToFly( *pFlyFormat, *pNewFormat, pSet.get(), bKeepOrient ))
         {
             SwFlyFrame* pFrame = pFlyFormat->GetFrame( &aPt );
             if( pFrame )
@@ -1225,7 +1222,7 @@ void SwFEShell::SetFrameFormat( SwFrameFormat *pNewFormat, bool bKeepOrient, Poi
             else
                 GetLayout()->SetAssertFlyPages();
         }
-        delete pSet;
+        pSet.reset();
 
         EndAllActionAndCall();
     }
diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx
index 81631f659f96..c841bb322d0e 100644
--- a/sw/source/core/frmedt/feshview.cxx
+++ b/sw/source/core/frmedt/feshview.cxx
@@ -570,15 +570,14 @@ bool SwFEShell::MoveAnchor( SwMove nDir )
             // re-created. Thus, delete all fly frames except the <this> before the
             // anchor attribute is change and re-create them afterwards.
             {
-                SwHandleAnchorNodeChg* pHandleAnchorNodeChg( nullptr );
+                std::unique_ptr<SwHandleAnchorNodeChg> pHandleAnchorNodeChg;
                 SwFlyFrameFormat* pFlyFrameFormat( dynamic_cast<SwFlyFrameFormat*>(&rFormat) );
                 if ( pFlyFrameFormat )
                 {
-                    pHandleAnchorNodeChg =
-                        new SwHandleAnchorNodeChg( *pFlyFrameFormat, aAnch );
+                    pHandleAnchorNodeChg.reset(
+                        new SwHandleAnchorNodeChg( *pFlyFrameFormat, aAnch ));
                 }
                 rFormat.GetDoc()->SetAttr( aAnch, rFormat );
-                delete pHandleAnchorNodeChg;
             }
             // #i28701# - no call of method
             // <CheckCharRectAndTopOfLine()> for to-character anchored
diff --git a/sw/source/core/layout/flyincnt.cxx b/sw/source/core/layout/flyincnt.cxx
index a89ea5871609..77772d0e6259 100644
--- a/sw/source/core/layout/flyincnt.cxx
+++ b/sw/source/core/layout/flyincnt.cxx
@@ -65,11 +65,11 @@ void SwFlyInContentFrame::SetRefPoint( const Point& rPoint,
 {
     // OD 2004-05-27 #i26791# - member <aRelPos> moved to <SwAnchoredObject>
     OSL_ENSURE( rPoint != aRef || rRelAttr != GetCurrRelPos(), "SetRefPoint: no change" );
-    SwFlyNotify *pNotify = nullptr;
+    std::unique_ptr<SwFlyNotify> pNotify;
     // No notify at a locked fly frame, if a fly frame is locked, there's
     // already a SwFlyNotify object on the stack (MakeAll).
     if( !IsLocked() )
-        pNotify = new SwFlyNotify( this );
+        pNotify.reset(new SwFlyNotify( this ));
     aRef = rPoint;
     SetCurrRelPos( rRelAttr );
     SwRectFnSet aRectFnSet(GetAnchorFrame());
@@ -87,7 +87,7 @@ void SwFlyInContentFrame::SetRefPoint( const Point& rPoint,
         setFrameAreaPositionValid(false);
         m_bInvalid  = true;
         Calc(getRootFrame()->GetCurrShell()->GetOut());
-        delete pNotify;
+        pNotify.reset();
     }
 }
 
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index 1290c125427e..2bbbab22b2a5 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -2633,7 +2633,7 @@ bool SwLayoutFrame::MoveLowerFootnotes( SwContentFrame *pStart, SwFootnoteBossFr
 
     OSL_ENSURE( pOldBoss->IsInSct() == pNewBoss->IsInSct(),
             "MoveLowerFootnotes: Section confusion" );
-    SwFootnoteFrames *pFootnoteArr;
+    std::unique_ptr<SwFootnoteFrames> pFootnoteArr;
     SwLayoutFrame* pNewChief = nullptr;
     SwLayoutFrame* pOldChief = nullptr;
 
@@ -2647,7 +2647,7 @@ bool SwLayoutFrame::MoveLowerFootnotes( SwContentFrame *pStart, SwFootnoteBossFr
 
     if (bFoundCandidate)
     {
-        pFootnoteArr = new SwFootnoteFrames;
+        pFootnoteArr.reset(new SwFootnoteFrames);
         pOldChief = pOldBoss->FindFootnoteBossFrame( true );
         pNewChief = pNewBoss->FindFootnoteBossFrame( true );
         while( pOldChief->IsAnLower( pStart ) )
@@ -2659,8 +2659,7 @@ bool SwLayoutFrame::MoveLowerFootnotes( SwContentFrame *pStart, SwFootnoteBossFr
         }
         if( pFootnoteArr->empty() )
         {
-            delete pFootnoteArr;
-            pFootnoteArr = nullptr;
+            pFootnoteArr.reset();
         }
     }
     else
@@ -2673,7 +2672,7 @@ bool SwLayoutFrame::MoveLowerFootnotes( SwContentFrame *pStart, SwFootnoteBossFr
         if( pFootnoteArr )
         {
             static_cast<SwFootnoteBossFrame*>(pNewChief)->MoveFootnotes_( *pFootnoteArr, true );
-            delete pFootnoteArr;
+            pFootnoteArr.reset();
         }
         bMoved = true;
 


More information about the Libreoffice-commits mailing list