diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-23 14:28:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-04-24 08:22:30 +0200 |
commit | ab2b4c0e1378072f05eee6b2c1bf6df311d6f1b3 (patch) | |
tree | d0acd7a74189c7e6d5ac50e0f604df0a52f7bd50 | |
parent | 4acc2daacbb83869f5e576427b3743ddf80a5578 (diff) |
loplugin:useuniqueptr in I18nHelper
Change-Id: I46ba0150bc4ca39fd781b8b979e960df0cffc7d4
Reviewed-on: https://gerrit.libreoffice.org/53355
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/vcl/i18nhelp.hxx | 5 | ||||
-rw-r--r-- | vcl/source/app/i18nhelp.cxx | 17 |
2 files changed, 9 insertions, 13 deletions
diff --git a/include/vcl/i18nhelp.hxx b/include/vcl/i18nhelp.hxx index b3a14255ca06..a18d7fcd4958 100644 --- a/include/vcl/i18nhelp.hxx +++ b/include/vcl/i18nhelp.hxx @@ -25,6 +25,7 @@ #include <osl/mutex.hxx> #include <rtl/ustring.hxx> #include <vcl/dllapi.h> +#include <memory> namespace com { namespace sun { @@ -51,8 +52,8 @@ class VCL_DLLPUBLIC I18nHelper LanguageTag maLanguageTag; css::uno::Reference< css::uno::XComponentContext > m_xContext; - LocaleDataWrapper* mpLocaleDataWrapper; - utl::TransliterationWrapper* mpTransliterationWrapper; + std::unique_ptr<LocaleDataWrapper> mpLocaleDataWrapper; + std::unique_ptr<utl::TransliterationWrapper> mpTransliterationWrapper; bool mbTransliterateIgnoreCase; diff --git a/vcl/source/app/i18nhelp.cxx b/vcl/source/app/i18nhelp.cxx index ca4ddbbfcca8..acbb9311d03b 100644 --- a/vcl/source/app/i18nhelp.cxx +++ b/vcl/source/app/i18nhelp.cxx @@ -48,11 +48,8 @@ vcl::I18nHelper::~I18nHelper() void vcl::I18nHelper::ImplDestroyWrappers() { - delete mpLocaleDataWrapper; - mpLocaleDataWrapper = nullptr; - - delete mpTransliterationWrapper; - mpTransliterationWrapper= nullptr; + mpLocaleDataWrapper.reset(); + mpTransliterationWrapper.reset(); } utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() const @@ -63,7 +60,7 @@ utl::TransliterationWrapper& vcl::I18nHelper::ImplGetTransliterationWrapper() co if ( mbTransliterateIgnoreCase ) nModules |= TransliterationFlags::IGNORE_CASE; - const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper = new utl::TransliterationWrapper( m_xContext, nModules ); + const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper.reset(new utl::TransliterationWrapper( m_xContext, nModules )); const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper->loadModuleIfNeeded( maLanguageTag.getLanguageType() ); } return *mpTransliterationWrapper; @@ -73,7 +70,7 @@ LocaleDataWrapper& vcl::I18nHelper::ImplGetLocaleDataWrapper() const { if ( !mpLocaleDataWrapper ) { - const_cast<vcl::I18nHelper*>(this)->mpLocaleDataWrapper = new LocaleDataWrapper( m_xContext, maLanguageTag ); + const_cast<vcl::I18nHelper*>(this)->mpLocaleDataWrapper.reset(new LocaleDataWrapper( m_xContext, maLanguageTag )); } return *mpLocaleDataWrapper; } @@ -118,8 +115,7 @@ sal_Int32 vcl::I18nHelper::CompareString( const OUString& rStr1, const OUString& // Change mbTransliterateIgnoreCase and destroy the wrapper, next call to // ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase const_cast<vcl::I18nHelper*>(this)->mbTransliterateIgnoreCase = false; - delete const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper; - const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper = nullptr; + const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper.reset(); } OUString aStr1( filterFormattingChars(rStr1) ); @@ -136,8 +132,7 @@ bool vcl::I18nHelper::MatchString( const OUString& rStr1, const OUString& rStr2 // Change mbTransliterateIgnoreCase and destroy the wrapper, next call to // ImplGetTransliterationWrapper() will create a wrapper with the correct bIgnoreCase const_cast<vcl::I18nHelper*>(this)->mbTransliterateIgnoreCase = true; - delete const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper; - const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper = nullptr; + const_cast<vcl::I18nHelper*>(this)->mpTransliterationWrapper.reset(); } OUString aStr1( filterFormattingChars(rStr1) ); |