summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-06-03 20:09:16 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-06-03 22:44:16 +0200
commit2c0157fbe9b9338f98e66d300664fe3c710eb415 (patch)
tree603694d048ea900b8834ddf6b9988d854d2e4983 /sw
parent16b0ad3cf76d9932ebbd169af64b7ad292e68426 (diff)
cid#1602449 Resource leak
Change-Id: Ide5575adb3346a0ad36a484078dc02ef46a4c043 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168389 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/docsort.cxx21
1 files changed, 11 insertions, 10 deletions
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index df5aaf6e5c89..8f5e70d5110d 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -313,7 +313,7 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt)
}
std::optional<SwPaM> pRedlPam;
- SwUndoRedlineSort* pRedlUndo = nullptr;
+ std::unique_ptr<SwUndoRedlineSort> xRedlUndo;
SwUndoSort* pUndoSort = nullptr;
// To-Do - add 'SwExtraRedlineTable' also ?
@@ -328,7 +328,7 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt)
{
if( bUndo )
{
- pRedlUndo = new SwUndoRedlineSort( *pRedlPam,rOpt );
+ xRedlUndo.reset(new SwUndoRedlineSort(*pRedlPam, rOpt));
GetIDocumentUndoRedo().DoUndo(false);
}
// First copy the range
@@ -356,8 +356,8 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt)
if (pCNd)
pRedlPam->GetPoint()->SetContent( nCLen );
- if( pRedlUndo )
- pRedlUndo->SetValues( rPaM );
+ if (xRedlUndo)
+ xRedlUndo->SetValues(rPaM);
}
else
{
@@ -380,7 +380,7 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt)
SwNodeOffset nBeg = pStart->GetNodeIndex();
SwNodeRange aRg( aStart, aStart );
- if( bUndo && !pRedlUndo )
+ if (bUndo && !xRedlUndo)
{
pUndoSort = new SwUndoSort(rPaM, rOpt);
GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndoSort));
@@ -412,12 +412,13 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt)
if( pRedlPam )
{
- if( pRedlUndo )
+ SwUndoRedlineSort* pRedlUndo = xRedlUndo.get();
+ if (pRedlUndo)
{
- pRedlUndo->SetSaveRange( *pRedlPam );
+ xRedlUndo->SetSaveRange(*pRedlPam);
// UGLY: temp. enable Undo
GetIDocumentUndoRedo().DoUndo(true);
- GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pRedlUndo) );
+ GetIDocumentUndoRedo().AppendUndo(std::move(xRedlUndo));
GetIDocumentUndoRedo().DoUndo(false);
}
@@ -437,13 +438,13 @@ bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt)
// the sorted range is inserted
getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( RedlineType::Insert, *pRedlPam ), true);
- if( pRedlUndo )
+ if (pRedlUndo)
{
SwNodeIndex aInsEndIdx( pRedlPam->GetMark()->GetNode(), -1 );
SwContentNode *const pContentNode = aInsEndIdx.GetNode().GetContentNode();
pRedlPam->GetMark()->Assign( *pContentNode, pContentNode->Len() );
- pRedlUndo->SetValues( *pRedlPam );
+ pRedlUndo->SetValues(*pRedlPam);
}
pRedlPam.reset();