diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-05 11:23:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-02-07 13:09:52 +0100 |
commit | ef83e5fba10187a0ec50dab6d381ff2d4ecdc5d2 (patch) | |
tree | 4348f55b6ee1624aaf9326f9ad8dba4cc1b12778 /svx/source | |
parent | 420d2c48bc2afc262d04d20ecab90517d07f3aa8 (diff) |
loplugin:useuniqueptr in SdrOutlinerCache
Change-Id: Ie34f1bd9e46bf767ec2e1918c2b88cf289f4b410
Reviewed-on: https://gerrit.libreoffice.org/49330
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/inc/svdoutlinercache.hxx | 5 | ||||
-rw-r--r-- | svx/source/svdraw/svdoutlinercache.cxx | 21 |
2 files changed, 7 insertions, 19 deletions
diff --git a/svx/source/inc/svdoutlinercache.hxx b/svx/source/inc/svdoutlinercache.hxx index f3aa9ec43107..30f5c6699e11 100644 --- a/svx/source/inc/svdoutlinercache.hxx +++ b/svx/source/inc/svdoutlinercache.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SVX_SOURCE_INC_SVDOUTLINERCACHE_HXX #include <sal/types.h> +#include <memory> #include <vector> #include <set> @@ -32,8 +33,8 @@ class SdrOutlinerCache { private: SdrModel* mpModel; - std::vector< SdrOutliner* > maModeOutline; - std::vector< SdrOutliner* > maModeText; + std::vector< std::unique_ptr<SdrOutliner> > maModeOutline; + std::vector< std::unique_ptr<SdrOutliner> > maModeText; std::set< SdrOutliner* > maActiveOutliners; public: diff --git a/svx/source/svdraw/svdoutlinercache.cxx b/svx/source/svdraw/svdoutlinercache.cxx index bd95f359fe1a..419837070d4f 100644 --- a/svx/source/svdraw/svdoutlinercache.cxx +++ b/svx/source/svdraw/svdoutlinercache.cxx @@ -36,12 +36,12 @@ SdrOutliner* SdrOutlinerCache::createOutliner( OutlinerMode nOutlinerMode ) if( (OutlinerMode::OutlineObject == nOutlinerMode) && !maModeOutline.empty() ) { - pOutliner = maModeOutline.back(); + pOutliner = maModeOutline.back().release(); maModeOutline.pop_back(); } else if( (OutlinerMode::TextObject == nOutlinerMode) && !maModeText.empty() ) { - pOutliner = maModeText.back(); + pOutliner = maModeText.back().release(); maModeText.pop_back(); } else @@ -57,19 +57,6 @@ SdrOutliner* SdrOutlinerCache::createOutliner( OutlinerMode nOutlinerMode ) SdrOutlinerCache::~SdrOutlinerCache() { - for( auto candA : maModeOutline ) - { - delete candA; - } - - maModeOutline.clear(); - - for( auto candB : maModeText ) - { - delete candB; - } - - maModeText.clear(); } void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner ) @@ -80,7 +67,7 @@ void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner ) if( OutlinerMode::OutlineObject == nOutlMode ) { - maModeOutline.push_back(pOutliner); + maModeOutline.emplace_back(pOutliner); pOutliner->Clear(); pOutliner->SetVertical( false ); @@ -89,7 +76,7 @@ void SdrOutlinerCache::disposeOutliner( SdrOutliner* pOutliner ) } else if( OutlinerMode::TextObject == nOutlMode ) { - maModeText.push_back(pOutliner); + maModeText.emplace_back(pOutliner); pOutliner->Clear(); pOutliner->SetVertical( false ); |