use std::unique_ptr in SwUndoTransliterate

Change-Id: I4c3480104cbec53a395bd11702949984fca452a0
Reviewed-on: https://gerrit.libreoffice.org/43899
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2017-10-26 13:29:38 +02:00
parent bbb104d70d
commit 1a6b373d99
2 changed files with 3 additions and 5 deletions

View File

@@ -69,7 +69,7 @@ public:
struct UndoTransliterate_Data; struct UndoTransliterate_Data;
class SwUndoTransliterate : public SwUndo, public SwUndRng class SwUndoTransliterate : public SwUndo, public SwUndRng
{ {
std::vector< UndoTransliterate_Data * > aChanges; std::vector< std::unique_ptr<UndoTransliterate_Data> > aChanges;
TransliterationFlags nType; TransliterationFlags nType;
void DoTransliterate(SwDoc & rDoc, SwPaM const & rPam); void DoTransliterate(SwDoc & rDoc, SwPaM const & rPam);

View File

@@ -345,8 +345,6 @@ SwUndoTransliterate::SwUndoTransliterate(
SwUndoTransliterate::~SwUndoTransliterate() SwUndoTransliterate::~SwUndoTransliterate()
{ {
for (UndoTransliterate_Data* p : aChanges)
delete p;
} }
void SwUndoTransliterate::UndoImpl(::sw::UndoRedoContext & rContext) void SwUndoTransliterate::UndoImpl(::sw::UndoRedoContext & rContext)
@@ -389,7 +387,7 @@ void SwUndoTransliterate::AddChanges( SwTextNode& rTNd,
rTNd.GetIndex(), nStart, (sal_Int32)nOffsLen, rTNd.GetIndex(), nStart, (sal_Int32)nOffsLen,
rTNd.GetText().copy(nStart, nLen)); rTNd.GetText().copy(nStart, nLen));
aChanges.push_back( pNew ); aChanges.push_back( std::unique_ptr<UndoTransliterate_Data>(pNew) );
const sal_Int32* pOffsets = rOffsets.getConstArray(); const sal_Int32* pOffsets = rOffsets.getConstArray();
// where did we need less memory ? // where did we need less memory ?
@@ -426,7 +424,7 @@ void SwUndoTransliterate::AddChanges( SwTextNode& rTNd,
// but this data must moved every time to the last in the chain! // but this data must moved every time to the last in the chain!
for (size_t i = 0; i + 1 < aChanges.size(); ++i) // check all changes but not the current one for (size_t i = 0; i + 1 < aChanges.size(); ++i) // check all changes but not the current one
{ {
UndoTransliterate_Data* pD = aChanges[i]; UndoTransliterate_Data* pD = aChanges[i].get();
if( pD->nNdIdx == pNew->nNdIdx && pD->pHistory ) if( pD->nNdIdx == pNew->nNdIdx && pD->pHistory )
{ {
// same node and have a history? // same node and have a history?