summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-12-19 10:52:51 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-12-19 12:34:05 +0100
commitf12b6893cfee3df23756f752adad299f1368f04b (patch)
tree50d8d1aecd94c7b6ef98d6eaec7f2f5728c7eed4
parent415c2e54e758172ff4f614239128b2aa0ddad49e (diff)
use unique_ptr in StringResourceImpl
Change-Id: Id7a44c4ac5643aae96cb707d2cca217f8535ee63 Reviewed-on: https://gerrit.libreoffice.org/65404 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--scripting/source/stringresource/stringresource.cxx44
-rw-r--r--scripting/source/stringresource/stringresource.hxx2
2 files changed, 20 insertions, 26 deletions
diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx
index bb700290ff25..bf4260646caa 100644
--- a/scripting/source/stringresource/stringresource.cxx
+++ b/scripting/source/stringresource/stringresource.cxx
@@ -38,6 +38,7 @@
#include <com/sun/star/ucb/SimpleFileAccess.hpp>
#include <osl/diagnose.h>
+#include <o3tl/make_unique.hxx>
#include <rtl/tencinfo.h>
#include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx>
@@ -337,8 +338,8 @@ void StringResourceImpl::setDefaultLocale( const Locale& locale )
{
if( m_pDefaultLocaleItem )
{
- LocaleItem* pChangedDefaultLocaleItem = new LocaleItem( m_pDefaultLocaleItem->m_locale );
- m_aChangedDefaultLocaleVector.push_back( pChangedDefaultLocaleItem );
+ m_aChangedDefaultLocaleVector.push_back(
+ o3tl::make_unique<LocaleItem>( m_pDefaultLocaleItem->m_locale ) );
}
m_pDefaultLocaleItem = pLocaleItem;
@@ -523,8 +524,8 @@ void StringResourceImpl::removeLocale( const Locale& locale )
m_nNextUniqueNumericId = 0;
if( m_pDefaultLocaleItem )
{
- LocaleItem* pChangedDefaultLocaleItem = new LocaleItem( m_pDefaultLocaleItem->m_locale );
- m_aChangedDefaultLocaleVector.push_back( pChangedDefaultLocaleItem );
+ m_aChangedDefaultLocaleVector.push_back(
+ o3tl::make_unique<LocaleItem>( m_pDefaultLocaleItem->m_locale ) );
}
m_pCurrentLocaleItem = nullptr;
m_pDefaultLocaleItem = nullptr;
@@ -937,20 +938,17 @@ void StringResourcePersistenceImpl::implStoreAtStorage
{
for( auto& pLocaleItem : m_aChangedDefaultLocaleVector )
{
- if( pLocaleItem != nullptr )
- {
- OUString aStreamName = implGetFileNameForLocaleItem( pLocaleItem, m_aNameBase );
- aStreamName += ".default";
-
- try
- {
- Storage->removeElement( aStreamName );
- }
- catch( Exception& )
- {}
+ OUString aStreamName = implGetFileNameForLocaleItem( pLocaleItem.get(), m_aNameBase );
+ aStreamName += ".default";
- delete pLocaleItem;
+ try
+ {
+ Storage->removeElement( aStreamName );
}
+ catch( Exception& )
+ {}
+
+ pLocaleItem.reset();
}
m_aChangedDefaultLocaleVector.clear();
}
@@ -1019,15 +1017,11 @@ void StringResourcePersistenceImpl::implKillChangedDefaultFiles
// Delete files for changed defaults
for( auto& pLocaleItem : m_aChangedDefaultLocaleVector )
{
- if( pLocaleItem != nullptr )
- {
- OUString aCompleteFileName =
- implGetPathForLocaleItem( pLocaleItem, aNameBase, Location, true );
- if( xFileAccess->exists( aCompleteFileName ) )
- xFileAccess->kill( aCompleteFileName );
-
- delete pLocaleItem;
- }
+ OUString aCompleteFileName =
+ implGetPathForLocaleItem( pLocaleItem.get(), aNameBase, Location, true );
+ if( xFileAccess->exists( aCompleteFileName ) )
+ xFileAccess->kill( aCompleteFileName );
+ pLocaleItem.reset();
}
m_aChangedDefaultLocaleVector.clear();
}
diff --git a/scripting/source/stringresource/stringresource.hxx b/scripting/source/stringresource/stringresource.hxx
index e99088b001cf..13ad55a327ec 100644
--- a/scripting/source/stringresource/stringresource.hxx
+++ b/scripting/source/stringresource/stringresource.hxx
@@ -82,7 +82,7 @@ struct LocaleItem
{}
};
-typedef std::vector< LocaleItem* > LocaleItemVector;
+typedef std::vector< std::unique_ptr<LocaleItem> > LocaleItemVector;
typedef ::cppu::WeakImplHelper<
css::lang::XServiceInfo,