From 78a6ce17f06fbe13b806fd563e85a4fe60d3bcfc Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 13 Dec 2017 15:47:02 +0200 Subject: DELETEZ->std::unique_ptr in toolkit,unotools Change-Id: I2263e233ae03575e53ab4e7894a7507423afd32e Reviewed-on: https://gerrit.libreoffice.org/46397 Tested-by: Jenkins Reviewed-by: Noel Grandin --- unotools/source/config/saveopt.cxx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'unotools') diff --git a/unotools/source/config/saveopt.cxx b/unotools/source/config/saveopt.cxx index cdb66c6fabe4..35b721702f21 100644 --- a/unotools/source/config/saveopt.cxx +++ b/unotools/source/config/saveopt.cxx @@ -45,11 +45,11 @@ class SvtLoadOptions_Impl; struct SvtLoadSaveOptions_Impl { - SvtSaveOptions_Impl* pSaveOpt; - SvtLoadOptions_Impl* pLoadOpt; + std::unique_ptr pSaveOpt; + std::unique_ptr pLoadOpt; }; -static SvtLoadSaveOptions_Impl* pOptions = nullptr; +static std::unique_ptr pOptions; static sal_Int32 nRefCount = 0; class SvtSaveOptions_Impl : public utl::ConfigItem @@ -802,14 +802,14 @@ SvtSaveOptions::SvtSaveOptions() ::osl::MutexGuard aGuard( LocalSingleton::get() ); if ( !pOptions ) { - pOptions = new SvtLoadSaveOptions_Impl; - pOptions->pSaveOpt = new SvtSaveOptions_Impl; - pOptions->pLoadOpt = new SvtLoadOptions_Impl; + pOptions.reset(new SvtLoadSaveOptions_Impl); + pOptions->pSaveOpt.reset(new SvtSaveOptions_Impl); + pOptions->pLoadOpt.reset( new SvtLoadOptions_Impl); ItemHolder1::holdConfigItem(EItem::SaveOptions); } ++nRefCount; - pImp = pOptions; + pImp = pOptions.get(); } SvtSaveOptions::~SvtSaveOptions() @@ -823,9 +823,7 @@ SvtSaveOptions::~SvtSaveOptions() if ( pOptions->pLoadOpt->IsModified() ) pOptions->pLoadOpt->Commit(); - DELETEZ( pOptions->pLoadOpt ); - DELETEZ( pOptions->pSaveOpt ); - DELETEZ( pOptions ); + pOptions.reset(); } } -- cgit