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

Noel Grandin noel.grandin at collabora.co.uk
Wed Jun 20 07:47:57 UTC 2018


 cui/source/options/optchart.cxx |   16 +++++++---------
 cui/source/options/optchart.hxx |    4 ++--
 2 files changed, 9 insertions(+), 11 deletions(-)

New commits:
commit 4ab105d14148932f6d848b56678e942c50631964
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jun 11 15:14:05 2018 +0200

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

diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx
index d9c92433c006..02676c9d63f7 100644
--- a/cui/source/options/optchart.cxx
+++ b/cui/source/options/optchart.cxx
@@ -135,20 +135,20 @@ SvxDefaultColorOptPage::SvxDefaultColorOptPage(vcl::Window* pParent, const SfxIt
     m_pValSetColorBox->SetExtraSpacing( 0 );
     m_pValSetColorBox->Show();
 
-    pChartOptions = new SvxChartOptions;
+    pChartOptions.reset(new SvxChartOptions);
     pColorList = XColorList::CreateStdColorList();
 
     const SfxPoolItem* pItem = nullptr;
     if ( rInAttrs.GetItemState( SID_SCH_EDITOPTIONS, false, &pItem ) == SfxItemState::SET )
     {
-        pColorConfig = static_cast< SvxChartColorTableItem* >(pItem->Clone());
+        pColorConfig.reset(static_cast< SvxChartColorTableItem* >(pItem->Clone()));
     }
     else
     {
         SvxChartColorTable aTable;
         aTable.useDefault();
-        pColorConfig = new SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aTable );
-        pColorConfig->SetOptions( pChartOptions );
+        pColorConfig.reset(new SvxChartColorTableItem( SID_SCH_EDITOPTIONS, aTable ));
+        pColorConfig->SetOptions( pChartOptions.get() );
     }
 
     Construct();
@@ -167,10 +167,8 @@ void SvxDefaultColorOptPage::dispose()
         pChartOptions->SetDefaultColors( pColorConfig->GetColorList() );
         pChartOptions->Commit();
 
-        delete pColorConfig;
-        pColorConfig = nullptr;
-        delete pChartOptions;
-        pChartOptions = nullptr;
+        pColorConfig.reset();
+        pChartOptions.reset();
     }
     m_pLbChartColors.clear();
     m_pValSetColorBox.clear();
@@ -198,7 +196,7 @@ VclPtr<SfxTabPage> SvxDefaultColorOptPage::Create( TabPageParent pParent, const
 bool SvxDefaultColorOptPage::FillItemSet( SfxItemSet* rOutAttrs )
 {
     if( pColorConfig )
-        rOutAttrs->Put( *static_cast< SfxPoolItem* >(pColorConfig) );
+        rOutAttrs->Put( *pColorConfig );
 
     return true;
 }
diff --git a/cui/source/options/optchart.hxx b/cui/source/options/optchart.hxx
index 97ae4b2ed509..fc7d01091871 100644
--- a/cui/source/options/optchart.hxx
+++ b/cui/source/options/optchart.hxx
@@ -40,8 +40,8 @@ private:
     VclPtr<PushButton>             m_pPBAdd;
     VclPtr<PushButton>             m_pPBRemove;
 
-    SvxChartOptions*        pChartOptions;
-    SvxChartColorTableItem* pColorConfig;
+    std::unique_ptr<SvxChartOptions>        pChartOptions;
+    std::unique_ptr<SvxChartColorTableItem> pColorConfig;
     XColorListRef           pColorList;
     ImpColorList            aColorList;
 


More information about the Libreoffice-commits mailing list