include/unotools/syslocaleoptions.hxx | 3 - unotools/source/config/syslocaleoptions.cxx | 54 ++++++++++++---------------- 2 files changed, 26 insertions(+), 31 deletions(-)
New commits: commit 73679ee0a31e3f70ace5136a8e41cbeb1f00c238 Author: Julien Nabet <serval2...@yahoo.fr> Date: Fri Nov 11 23:38:17 2016 +0100 Copycat SvtSysLocale_Impl for SvtSysLocaleOptions_Impl and so avoid warn:unotools.config:6728:1:unotools/source/config/configmgr.cxx:167: ConfigManager not empty when exiting LO See http://nabble.documentfoundation.org/OSL-ASSERT-items-empty-because-of-Setup-L10N-td4199284.html Thank you Eike for the hint! Change-Id: I4b374a075ad8f1ef10a71f3a9424986154613aef Reviewed-on: https://gerrit.libreoffice.org/30787 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/unotools/syslocaleoptions.hxx b/include/unotools/syslocaleoptions.hxx index d9e0828..f5cb835 100644 --- a/include/unotools/syslocaleoptions.hxx +++ b/include/unotools/syslocaleoptions.hxx @@ -43,8 +43,7 @@ namespace osl { class Mutex; } class SAL_WARN_UNUSED UNOTOOLS_DLLPUBLIC SvtSysLocaleOptions : public utl::detail::Options { - static SvtSysLocaleOptions_Impl* pOptions; - static sal_Int32 nRefCount; + std::shared_ptr<SvtSysLocaleOptions_Impl> pImpl; UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetMutex(); virtual void ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 nHint ) override; diff --git a/unotools/source/config/syslocaleoptions.cxx b/unotools/source/config/syslocaleoptions.cxx index b3d7647..9b24977 100644 --- a/unotools/source/config/syslocaleoptions.cxx +++ b/unotools/source/config/syslocaleoptions.cxx @@ -38,10 +38,9 @@ using namespace utl; using namespace com::sun::star::uno; using namespace com::sun::star::lang; -SvtSysLocaleOptions_Impl* SvtSysLocaleOptions::pOptions = nullptr; -sal_Int32 SvtSysLocaleOptions::nRefCount = 0; namespace { + std::weak_ptr<SvtSysLocaleOptions_Impl> g_pSysLocaleOptions; struct CurrencyChangeLink : public rtl::Static<Link<LinkParamNone*,void>, CurrencyChangeLink> {}; } @@ -513,25 +512,22 @@ void SvtSysLocaleOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNa SvtSysLocaleOptions::SvtSysLocaleOptions() { MutexGuard aGuard( GetMutex() ); - if ( !pOptions ) + pImpl = g_pSysLocaleOptions.lock(); + if ( !pImpl ) { - pOptions = new SvtSysLocaleOptions_Impl; + pImpl = std::make_shared<SvtSysLocaleOptions_Impl>(); + g_pSysLocaleOptions = pImpl; if (!utl::ConfigManager::IsAvoidConfig()) ItemHolder1::holdConfigItem(E_SYSLOCALEOPTIONS); } - ++nRefCount; - pOptions->AddListener(this); + pImpl->AddListener(this); } SvtSysLocaleOptions::~SvtSysLocaleOptions() { MutexGuard aGuard( GetMutex() ); - pOptions->RemoveListener(this); - if ( !--nRefCount ) - { - delete pOptions; - pOptions = nullptr; - } + pImpl->RemoveListener(this); + pImpl.reset(); } // static @@ -555,91 +551,91 @@ Mutex& SvtSysLocaleOptions::GetMutex() bool SvtSysLocaleOptions::IsModified() { MutexGuard aGuard( GetMutex() ); - return pOptions->IsModified(); + return pImpl->IsModified(); } void SvtSysLocaleOptions::Commit() { MutexGuard aGuard( GetMutex() ); - pOptions->Commit(); + pImpl->Commit(); } void SvtSysLocaleOptions::BlockBroadcasts( bool bBlock ) { MutexGuard aGuard( GetMutex() ); - pOptions->BlockBroadcasts( bBlock ); + pImpl->BlockBroadcasts( bBlock ); } const OUString& SvtSysLocaleOptions::GetLocaleConfigString() const { MutexGuard aGuard( GetMutex() ); - return pOptions->GetLocaleString(); + return pImpl->GetLocaleString(); } void SvtSysLocaleOptions::SetLocaleConfigString( const OUString& rStr ) { MutexGuard aGuard( GetMutex() ); - pOptions->SetLocaleString( rStr ); + pImpl->SetLocaleString( rStr ); } void SvtSysLocaleOptions::SetUILocaleConfigString( const OUString& rStr ) { MutexGuard aGuard( GetMutex() ); - pOptions->SetUILocaleString( rStr ); + pImpl->SetUILocaleString( rStr ); } const OUString& SvtSysLocaleOptions::GetCurrencyConfigString() const { MutexGuard aGuard( GetMutex() ); - return pOptions->GetCurrencyString(); + return pImpl->GetCurrencyString(); } void SvtSysLocaleOptions::SetCurrencyConfigString( const OUString& rStr ) { MutexGuard aGuard( GetMutex() ); - pOptions->SetCurrencyString( rStr ); + pImpl->SetCurrencyString( rStr ); } const OUString& SvtSysLocaleOptions::GetDatePatternsConfigString() const { MutexGuard aGuard( GetMutex() ); - return pOptions->GetDatePatternsString(); + return pImpl->GetDatePatternsString(); } void SvtSysLocaleOptions::SetDatePatternsConfigString( const OUString& rStr ) { MutexGuard aGuard( GetMutex() ); - pOptions->SetDatePatternsString( rStr ); + pImpl->SetDatePatternsString( rStr ); } bool SvtSysLocaleOptions::IsDecimalSeparatorAsLocale() const { MutexGuard aGuard( GetMutex() ); - return pOptions->IsDecimalSeparatorAsLocale(); + return pImpl->IsDecimalSeparatorAsLocale(); } void SvtSysLocaleOptions::SetDecimalSeparatorAsLocale( bool bSet) { MutexGuard aGuard( GetMutex() ); - pOptions->SetDecimalSeparatorAsLocale(bSet); + pImpl->SetDecimalSeparatorAsLocale(bSet); } bool SvtSysLocaleOptions::IsIgnoreLanguageChange() const { MutexGuard aGuard( GetMutex() ); - return pOptions->IsIgnoreLanguageChange(); + return pImpl->IsIgnoreLanguageChange(); } void SvtSysLocaleOptions::SetIgnoreLanguageChange( bool bSet) { MutexGuard aGuard( GetMutex() ); - pOptions->SetIgnoreLanguageChange(bSet); + pImpl->SetIgnoreLanguageChange(bSet); } bool SvtSysLocaleOptions::IsReadOnly( EOption eOption ) const { MutexGuard aGuard( GetMutex() ); - return pOptions->IsReadOnly( eOption ); + return pImpl->IsReadOnly( eOption ); } // static @@ -711,12 +707,12 @@ LanguageTag SvtSysLocaleOptions::GetLanguageTag() const const LanguageTag & SvtSysLocaleOptions::GetRealLanguageTag() const { - return pOptions->GetRealLocale(); + return pImpl->GetRealLocale(); } const LanguageTag & SvtSysLocaleOptions::GetRealUILanguageTag() const { - return pOptions->GetRealUILocale(); + return pImpl->GetRealUILocale(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits