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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Aug 15 06:42:11 UTC 2018


 cui/source/dialogs/iconcdlg.cxx |   14 ++++++--------
 cui/source/inc/iconcdlg.hxx     |    2 +-
 2 files changed, 7 insertions(+), 9 deletions(-)

New commits:
commit aad3b3b067987390b356a6901b85e0bfab46fab8
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Tue Aug 14 10:02:20 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 15 08:41:46 2018 +0200

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

diff --git a/cui/source/dialogs/iconcdlg.cxx b/cui/source/dialogs/iconcdlg.cxx
index bb9b8eadcb97..969bf03cdf36 100644
--- a/cui/source/dialogs/iconcdlg.cxx
+++ b/cui/source/dialogs/iconcdlg.cxx
@@ -198,11 +198,10 @@ void IconChoiceDialog::dispose()
     //aTabDlgOpt.SetWindowState(OStringToOUString(GetWindowState((WindowStateMask::X | WindowStateMask::Y | WindowStateMask::State | WindowStateMask::Minimized)), RTL_TEXTENCODING_ASCII_US));
     //aTabDlgOpt.SetPageID( mnCurrentPageId );
 
-    for (IconChoicePageData* pData : maPageList)
+    for (std::unique_ptr<IconChoicePageData> & pData : maPageList)
     {
         if ( pData->pPage )
             pData->pPage.disposeAndClear();
-        delete pData;
     }
     maPageList.clear();
 
@@ -232,8 +231,7 @@ SvxIconChoiceCtrlEntry* IconChoiceDialog::AddTabPage(
     CreatePage      pCreateFunc /* != 0 */
 )
 {
-    IconChoicePageData* pData = new IconChoicePageData ( nId, pCreateFunc );
-    maPageList.push_back( pData );
+    maPageList.emplace_back( new IconChoicePageData ( nId, pCreateFunc ) );
 
     SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->InsertEntry( rIconText, rChoiceIcon );
     pEntry->SetUserData ( reinterpret_cast<void*>(nId) );
@@ -431,7 +429,7 @@ void IconChoiceDialog::DeActivatePageImpl ()
         {
             // TODO refresh input set
             // flag all pages to be newly initialized
-            for (IconChoicePageData* pObj : maPageList)
+            for (auto & pObj : maPageList)
             {
                 if ( pObj->pPage.get() != pPage )
                     pObj->bRefresh = true;
@@ -540,7 +538,7 @@ void IconChoiceDialog::Start()
 bool IconChoiceDialog::QueryClose()
 {
     bool bRet = true;
-    for (IconChoicePageData* pData : maPageList)
+    for (auto & pData : maPageList)
     {
         if ( pData->pPage && !pData->pPage->QueryClose() )
         {
@@ -566,11 +564,11 @@ void IconChoiceDialog::Start_Impl()
 IconChoicePageData* IconChoiceDialog::GetPageData ( HyperLinkPageType nId )
 {
     IconChoicePageData *pRet = nullptr;
-    for (IconChoicePageData* pData : maPageList)
+    for (auto & pData : maPageList)
     {
         if ( pData->nId == nId )
         {
-            pRet = pData;
+            pRet = pData.get();
             break;
         }
     }
diff --git a/cui/source/inc/iconcdlg.hxx b/cui/source/inc/iconcdlg.hxx
index d72edc06b5a0..7f13cbfe40e1 100644
--- a/cui/source/inc/iconcdlg.hxx
+++ b/cui/source/inc/iconcdlg.hxx
@@ -96,7 +96,7 @@ class IconChoiceDialog : public SfxModalDialog
 private:
     friend class IconChoicePage;
 
-    std::vector< IconChoicePageData* > maPageList;
+    std::vector< std::unique_ptr<IconChoicePageData> > maPageList;
 
     VclPtr<SvtIconChoiceCtrl>       m_pIconCtrl;
 


More information about the Libreoffice-commits mailing list