tdf#89329: use shared_ptr for pImpl in syslocale
Change-Id: I646495e3538cb438a06765fe8cde252bad667bea Reviewed-on: https://gerrit.libreoffice.org/25969 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
This commit is contained in:
committed by
Noel Grandin
parent
60e57960f2
commit
3db4830c41
@@ -45,8 +45,7 @@ class UNOTOOLS_DLLPUBLIC SvtSysLocale
|
|||||||
{
|
{
|
||||||
friend class SvtSysLocale_Impl; // access to mutex
|
friend class SvtSysLocale_Impl; // access to mutex
|
||||||
|
|
||||||
static SvtSysLocale_Impl* pImpl;
|
std::shared_ptr<SvtSysLocale_Impl> pImpl;
|
||||||
static sal_Int32 nRefCount;
|
|
||||||
|
|
||||||
UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetMutex();
|
UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetMutex();
|
||||||
|
|
||||||
|
@@ -34,8 +34,7 @@
|
|||||||
using namespace osl;
|
using namespace osl;
|
||||||
using namespace com::sun::star;
|
using namespace com::sun::star;
|
||||||
|
|
||||||
SvtSysLocale_Impl* SvtSysLocale::pImpl = nullptr;
|
std::weak_ptr<SvtSysLocale_Impl> pSysLocale;
|
||||||
sal_Int32 SvtSysLocale::nRefCount = 0;
|
|
||||||
|
|
||||||
class SvtSysLocale_Impl : public utl::ConfigurationListener
|
class SvtSysLocale_Impl : public utl::ConfigurationListener
|
||||||
{
|
{
|
||||||
@@ -114,19 +113,18 @@ void SvtSysLocale_Impl::setDateAcceptancePatternsConfig()
|
|||||||
SvtSysLocale::SvtSysLocale()
|
SvtSysLocale::SvtSysLocale()
|
||||||
{
|
{
|
||||||
MutexGuard aGuard( GetMutex() );
|
MutexGuard aGuard( GetMutex() );
|
||||||
|
pImpl = pSysLocale.lock();
|
||||||
if ( !pImpl )
|
if ( !pImpl )
|
||||||
pImpl = new SvtSysLocale_Impl;
|
{
|
||||||
++nRefCount;
|
pImpl = std::make_shared<SvtSysLocale_Impl>();
|
||||||
|
pSysLocale = pImpl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SvtSysLocale::~SvtSysLocale()
|
SvtSysLocale::~SvtSysLocale()
|
||||||
{
|
{
|
||||||
MutexGuard aGuard( GetMutex() );
|
MutexGuard aGuard( GetMutex() );
|
||||||
if ( !--nRefCount )
|
pImpl.reset();
|
||||||
{
|
|
||||||
delete pImpl;
|
|
||||||
pImpl = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
Reference in New Issue
Block a user