diff options
author | Xisco Fauli <anistenis@gmail.com> | 2016-06-15 20:22:29 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-06-16 06:42:43 +0000 |
commit | 2400c271748f85355b689391d3aec405fcf3bff7 (patch) | |
tree | 11909e8b8a90ec6ccf2ec4fbe8f4a978361a2c8f /unotools/source | |
parent | 912f14c4e5c7db2a3acc0ae75995114ddfb12dea (diff) |
tdf#89329: use shared_ptr for pImpl in extendedsecurityoptions
Change-Id: I3d344c4872bbed9527f254a4eabc48534e38452f
Reviewed-on: https://gerrit.libreoffice.org/26326
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'unotools/source')
-rw-r--r-- | unotools/source/config/extendedsecurityoptions.cxx | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/unotools/source/config/extendedsecurityoptions.cxx b/unotools/source/config/extendedsecurityoptions.cxx index 3a4f5cbb4d5e..1fb58bdbe773 100644 --- a/unotools/source/config/extendedsecurityoptions.cxx +++ b/unotools/source/config/extendedsecurityoptions.cxx @@ -239,45 +239,28 @@ Sequence< OUString > SvtExtendedSecurityOptions_Impl::GetPropertyNames() return seqPropertyNames; } -// initialize static member -// DON'T DO IT IN YOUR HEADER! -// see definition for further information - -SvtExtendedSecurityOptions_Impl* SvtExtendedSecurityOptions::m_pDataContainer = nullptr; -sal_Int32 SvtExtendedSecurityOptions::m_nRefCount = 0; - -// constructor +std::weak_ptr<SvtExtendedSecurityOptions_Impl> m_pExtendedSecurityOptions; SvtExtendedSecurityOptions::SvtExtendedSecurityOptions() { // Global access, must be guarded (multithreading!). MutexGuard aGuard( GetInitMutex() ); - // Increase our refcount ... - ++m_nRefCount; - // ... and initialize our data container only if it not already exist! - if( m_pDataContainer == nullptr ) - { - m_pDataContainer = new SvtExtendedSecurityOptions_Impl; + m_pImpl = m_pExtendedSecurityOptions.lock(); + if( !m_pImpl ) + { + m_pImpl = std::make_shared<SvtExtendedSecurityOptions_Impl>(); + m_pExtendedSecurityOptions = m_pImpl; ItemHolder1::holdConfigItem(E_EXTENDEDSECURITYOPTIONS); } } -// destructor - SvtExtendedSecurityOptions::~SvtExtendedSecurityOptions() { // Global access, must be guarded (multithreading!) MutexGuard aGuard( GetInitMutex() ); - // Decrease our refcount. - --m_nRefCount; - // If last instance was deleted ... - // we must destroy our static data container! - if( m_nRefCount <= 0 ) - { - delete m_pDataContainer; - m_pDataContainer = nullptr; - } + + m_pImpl.reset(); } // public method @@ -285,7 +268,7 @@ SvtExtendedSecurityOptions::~SvtExtendedSecurityOptions() SvtExtendedSecurityOptions::OpenHyperlinkMode SvtExtendedSecurityOptions::GetOpenHyperlinkMode() { MutexGuard aGuard( GetInitMutex() ); - return m_pDataContainer->GetOpenHyperlinkMode(); + return m_pImpl->GetOpenHyperlinkMode(); } namespace |