summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/unotools/extendedsecurityoptions.hxx24
-rw-r--r--unotools/source/config/extendedsecurityoptions.cxx35
2 files changed, 11 insertions, 48 deletions
diff --git a/include/unotools/extendedsecurityoptions.hxx b/include/unotools/extendedsecurityoptions.hxx
index 070e377c8dfc..8726c72ad79d 100644
--- a/include/unotools/extendedsecurityoptions.hxx
+++ b/include/unotools/extendedsecurityoptions.hxx
@@ -24,6 +24,7 @@
#include <osl/mutex.hxx>
#include <rtl/ustring.hxx>
#include <unotools/options.hxx>
+#include <memory>
/*-************************************************************************************************************
@short forward declaration to our private date container implementation
@@ -52,17 +53,6 @@ class SAL_WARN_UNUSED UNOTOOLS_DLLPUBLIC SvtExtendedSecurityOptions : public utl
OPEN_ALWAYS
};
- /*-****************************************************************************************************
- @short standard constructor and destructor
- @descr This will initialize an instance with default values.
- We implement these class with a refcount mechanism! Every instance of this class increase it
- at create and decrease it at delete time - but all instances use the same data container!
- He is implemented as a static member ...
-
- @seealso member m_nRefCount
- @seealso member m_pDataContainer
- *//*-*****************************************************************************************************/
-
SvtExtendedSecurityOptions();
virtual ~SvtExtendedSecurityOptions();
@@ -83,17 +73,7 @@ class SAL_WARN_UNUSED UNOTOOLS_DLLPUBLIC SvtExtendedSecurityOptions : public utl
// private member
private:
-
- /*Attention
-
- Don't initialize these static members in these headers!
- a) Double defined symbols will be detected ...
- b) and unresolved externals exist at linking time.
- Do it in your source only.
- */
-
- static SvtExtendedSecurityOptions_Impl* m_pDataContainer;
- static sal_Int32 m_nRefCount;
+ std::shared_ptr<SvtExtendedSecurityOptions_Impl> m_pImpl;
}; // class SvtExtendedSecurityOptions
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