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

Noel Grandin noel.grandin at collabora.co.uk
Wed Jun 20 06:33:42 UTC 2018


 cui/source/dialogs/cuigaldlg.cxx |   28 ++++++++++++----------------
 cui/source/inc/cuigaldlg.hxx     |    2 +-
 2 files changed, 13 insertions(+), 17 deletions(-)

New commits:
commit 433fd79e00ee8fb935482f13ca5b270939aefa99
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jun 11 15:11:02 2018 +0200

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

diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx
index 90c8d01a0b0d..fe99c5373ede 100644
--- a/cui/source/dialogs/cuigaldlg.cxx
+++ b/cui/source/dialogs/cuigaldlg.cxx
@@ -756,9 +756,6 @@ void TPGalleryThemeProperties::dispose()
     xMediaPlayer.clear();
     xDialogListener.clear();
 
-    for (FilterEntry* i : aFilterEntryList) {
-        delete i;
-    }
     aFilterEntryList.clear();
 
     m_pCbbFileType.clear();
@@ -794,7 +791,6 @@ void TPGalleryThemeProperties::FillFilterList()
     GraphicFilter &rFilter = GraphicFilter::GetGraphicFilter();
     OUString            aExt;
     OUString            aName;
-    FilterEntry*        pFilterEntry;
     sal_uInt16          i, nKeyCount;
 
     // graphic filters
@@ -803,7 +799,7 @@ void TPGalleryThemeProperties::FillFilterList()
         aExt = rFilter.GetImportFormatShortName( i );
         aName = rFilter.GetImportFormatName( i );
         size_t entryIndex = 0;
-        FilterEntry* pTestEntry = aFilterEntryList.empty() ? nullptr : aFilterEntryList[ entryIndex ];
+        FilterEntry* pTestEntry = aFilterEntryList.empty() ? nullptr : aFilterEntryList[ entryIndex ].get();
         bool bInList = false;
 
         OUString aExtensions;
@@ -831,17 +827,17 @@ void TPGalleryThemeProperties::FillFilterList()
                 break;
             }
             pTestEntry = ( ++entryIndex < aFilterEntryList.size() )
-                       ? aFilterEntryList[ entryIndex ] : nullptr;
+                       ? aFilterEntryList[ entryIndex ].get() : nullptr;
         }
         if ( !bInList )
         {
-            pFilterEntry = new FilterEntry;
+            std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
             pFilterEntry->aFilterName = aExt;
             size_t pos = m_pCbbFileType->InsertEntry( aName );
             if ( pos < aFilterEntryList.size() ) {
-                aFilterEntryList.insert( aFilterEntryList.begin() + pos, pFilterEntry );
+                aFilterEntryList.insert( aFilterEntryList.begin() + pos, std::move(pFilterEntry) );
             } else {
-                aFilterEntryList.push_back( pFilterEntry );
+                aFilterEntryList.push_back( std::move(pFilterEntry) );
             }
         }
     }
@@ -857,7 +853,7 @@ void TPGalleryThemeProperties::FillFilterList()
         {
             OUString aFilterWildcard( aWildcard );
 
-            pFilterEntry = new FilterEntry;
+            std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
             pFilterEntry->aFilterName = aFilter.second.getToken( 0, ';', nIndex );
             nFirstExtFilterPos = m_pCbbFileType->InsertEntry(
                 addExtension(
@@ -868,10 +864,10 @@ void TPGalleryThemeProperties::FillFilterList()
             if ( nFirstExtFilterPos < aFilterEntryList.size() ) {
                 aFilterEntryList.insert(
                     aFilterEntryList.begin() + nFirstExtFilterPos,
-                    pFilterEntry
+                    std::move(pFilterEntry)
                 );
             } else {
-                aFilterEntryList.push_back( pFilterEntry );
+                aFilterEntryList.push_back( std::move(pFilterEntry) );
             }
         }
     }
@@ -915,16 +911,16 @@ void TPGalleryThemeProperties::FillFilterList()
         aExtensions = "*.*";
 #endif
 
-    pFilterEntry = new FilterEntry;
+    std::unique_ptr<FilterEntry> pFilterEntry(new FilterEntry);
     pFilterEntry->aFilterName = CuiResId(RID_SVXSTR_GALLERY_ALLFILES);
     pFilterEntry->aFilterName = addExtension( pFilterEntry->aFilterName, aExtensions );
     size_t pos = m_pCbbFileType->InsertEntry( pFilterEntry->aFilterName, 0 );
+    m_pCbbFileType->SetText( pFilterEntry->aFilterName );
     if ( pos < aFilterEntryList.size() ) {
-        aFilterEntryList.insert( aFilterEntryList.begin() + pos, pFilterEntry );
+        aFilterEntryList.insert( aFilterEntryList.begin() + pos, std::move(pFilterEntry) );
     } else {
-        aFilterEntryList.push_back( pFilterEntry );
+        aFilterEntryList.push_back( std::move(pFilterEntry) );
     }
-    m_pCbbFileType->SetText( pFilterEntry->aFilterName );
 }
 
 IMPL_LINK_NOARG(TPGalleryThemeProperties, SelectFileTypeHdl, ComboBox&, void)
diff --git a/cui/source/inc/cuigaldlg.hxx b/cui/source/inc/cuigaldlg.hxx
index bc82540bc3e3..d00a30b819c0 100644
--- a/cui/source/inc/cuigaldlg.hxx
+++ b/cui/source/inc/cuigaldlg.hxx
@@ -246,7 +246,7 @@ class TPGalleryThemeProperties : public SfxTabPage
 
     ExchangeData*           pData;
     std::vector<OUString>   aFoundList;
-    std::vector< FilterEntry* >
+    std::vector< std::unique_ptr<FilterEntry> >
                             aFilterEntryList;
     Timer                   aPreviewTimer;
     OUString                aLastFilterName;


More information about the Libreoffice-commits mailing list