diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-29 09:00:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-02 07:38:22 +0100 |
commit | 056ee671e2d3d15eb1dd9231f4628298cbbd0ede (patch) | |
tree | 3f835224b52649e5721c8630c71fbc95a32554f9 | |
parent | 904263cdd05d86756da68f0b843e876747dcf3a2 (diff) |
loplugin:useuniqueptr in TEParaPortions
Change-Id: I530c432176ea6bd338387d2f8855f9f477e8ca75
Reviewed-on: https://gerrit.libreoffice.org/49093
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | vcl/source/edit/textdat2.hxx | 6 | ||||
-rw-r--r-- | vcl/source/edit/textdata.cxx | 2 | ||||
-rw-r--r-- | vcl/source/edit/texteng.cxx | 3 | ||||
-rw-r--r-- | vcl/source/edit/textundo.cxx | 1 |
4 files changed, 3 insertions, 9 deletions
diff --git a/vcl/source/edit/textdat2.hxx b/vcl/source/edit/textdat2.hxx index cef44ae687b2..27b110b6e322 100644 --- a/vcl/source/edit/textdat2.hxx +++ b/vcl/source/edit/textdat2.hxx @@ -212,15 +212,15 @@ public: class TEParaPortions { private: - std::vector<TEParaPortion*> mvData; + std::vector<std::unique_ptr<TEParaPortion>> mvData; public: TEParaPortions() : mvData() {} ~TEParaPortions(); sal_uInt32 Count() const { return static_cast<sal_uInt32>(mvData.size()); } - TEParaPortion* GetObject( sal_uInt32 nIndex ) { return mvData[nIndex]; } - void Insert( TEParaPortion* pObject, sal_uInt32 nPos ) { mvData.insert( mvData.begin()+nPos, pObject ); } + TEParaPortion* GetObject( sal_uInt32 nIndex ) { return mvData[nIndex].get(); } + void Insert( TEParaPortion* pObject, sal_uInt32 nPos ) { mvData.emplace( mvData.begin()+nPos, pObject ); } void Remove( sal_uInt32 nPos ) { mvData.erase( mvData.begin()+nPos ); } }; diff --git a/vcl/source/edit/textdata.cxx b/vcl/source/edit/textdata.cxx index 72e8b3c309a8..bc8302174cab 100644 --- a/vcl/source/edit/textdata.cxx +++ b/vcl/source/edit/textdata.cxx @@ -267,8 +267,6 @@ void TEParaPortion::CorrectValuesBehindLastFormattedLine( sal_uInt16 nLastFormat TEParaPortions::~TEParaPortions() { - for (auto const& elem : mvData) - delete elem; } IdleFormatter::IdleFormatter() diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 6baa37e08d0a..06d96b716fe5 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -523,7 +523,6 @@ TextPaM TextEngine::ImpConnectParagraphs( sal_uInt32 nLeft, sal_uInt32 nRight ) pLeftPortion->MarkSelectionInvalid( aPaM.GetIndex() ); mpTEParaPortions->Remove( nRight ); - delete pRightPortion; // the right Node is deleted by EditDoc::ConnectParagraphs() return aPaM; @@ -601,7 +600,6 @@ TextPaM TextEngine::ImpDeleteText( const TextSelection& rSel ) void TextEngine::ImpRemoveParagraph( sal_uInt32 nPara ) { TextNode* pNode = mpDoc->GetNodes()[ nPara ]; - std::unique_ptr<TEParaPortion> xPortion(mpTEParaPortions->GetObject( nPara )); // the Node is handled by Undo and is deleted if appropriate mpDoc->GetNodes().erase( mpDoc->GetNodes().begin() + nPara ); @@ -611,7 +609,6 @@ void TextEngine::ImpRemoveParagraph( sal_uInt32 nPara ) delete pNode; mpTEParaPortions->Remove( nPara ); - xPortion.reset(); ImpParagraphRemoved( nPara ); } diff --git a/vcl/source/edit/textundo.cxx b/vcl/source/edit/textundo.cxx index 5c58bde20b8a..15cea12cba2e 100644 --- a/vcl/source/edit/textundo.cxx +++ b/vcl/source/edit/textundo.cxx @@ -165,7 +165,6 @@ void TextUndoDelPara::Redo() // pNode is not valid anymore in case an Undo joined paragraphs mpNode = GetDoc()->GetNodes()[ mnPara ]; - delete GetTEParaPortions()->GetObject( mnPara ); GetTEParaPortions()->Remove( mnPara ); // do not delete Node because of Undo! |