[Libreoffice-commits] core.git: sfx2/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Jan 23 10:17:59 UTC 2018


 sfx2/source/doc/doctemplates.cxx |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

New commits:
commit 18bc0ea4f26eb3ce020597d9feef9ee852a26096
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jan 16 15:47:16 2018 +0200

    loplugin:useuniqueptr in SfxDocTplService_Impl
    
    Change-Id: Iacda2920f632a6f21d852d843e97086a23479bbd
    Reviewed-on: https://gerrit.libreoffice.org/48370
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index eee0ac0363ac..61bf957b5713 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -185,7 +185,7 @@ class SfxDocTplService_Impl
     Sequence< OUString >        maTemplateDirs;
     Sequence< OUString >        maInternalTemplateDirs;
     OUString                    maRootURL;
-    std::vector< NamePair_Impl* > maNames;
+    std::vector< std::unique_ptr<NamePair_Impl> > maNames;
     lang::Locale                maLocale;
     Content                     maRootContent;
     bool                        mbIsInitialized : 1;
@@ -506,11 +506,11 @@ void SfxDocTplService_Impl::readFolderList()
     const size_t nCount = std::min(SAL_N_ELEMENTS(TEMPLATE_SHORT_NAMES_ARY), SAL_N_ELEMENTS(TEMPLATE_LONG_NAMES_ARY));
     for (size_t i = 0; i < nCount; ++i)
     {
-        NamePair_Impl* pPair = new NamePair_Impl;
+        std::unique_ptr<NamePair_Impl> pPair( new NamePair_Impl );
         pPair->maShortName  = OUString::createFromAscii(TEMPLATE_SHORT_NAMES_ARY[i]);
         pPair->maLongName   = SfxResId(TEMPLATE_LONG_NAMES_ARY[i]);
 
-        maNames.push_back( pPair );
+        maNames.push_back( std::move(pPair) );
     }
 }
 
@@ -519,7 +519,7 @@ OUString SfxDocTplService_Impl::getLongName( const OUString& rShortName )
 {
     OUString         aRet;
 
-    for (NamePair_Impl* pPair : maNames)
+    for (auto const & pPair : maNames)
     {
         if ( pPair->maShortName == rShortName )
         {
@@ -1086,9 +1086,6 @@ SfxDocTplService_Impl::SfxDocTplService_Impl( const uno::Reference< XComponentCo
 SfxDocTplService_Impl::~SfxDocTplService_Impl()
 {
     ::osl::MutexGuard aGuard( maMutex );
-
-    for (NamePair_Impl* p : maNames)
-        delete p;
     maNames.clear();
 }
 


More information about the Libreoffice-commits mailing list