Kaydet (Commit) ed8a2341 authored tarafından Michael Stahl's avatar Michael Stahl

properly prefix various global variables and hide them

Change-Id: I6b97e6a4c6ac4c0e26bcbb2b132b333920c16f19
üst f04c48a7
......@@ -376,20 +376,23 @@ bool SvtCJKOptions_Impl::IsReadOnly(SvtCJKOptions::EOption eOption) const
return bReadOnly;
}
// global
std::weak_ptr<SvtCJKOptions_Impl> pCJKOptions;
namespace {
namespace { struct theCJKOptionsMutex : public rtl::Static< ::osl::Mutex , theCJKOptionsMutex >{}; }
// global
std::weak_ptr<SvtCJKOptions_Impl> g_pCJKOptions;
struct theCJKOptionsMutex : public rtl::Static< ::osl::Mutex , theCJKOptionsMutex >{};
}
SvtCJKOptions::SvtCJKOptions(bool bDontLoad)
{
// Global access, must be guarded (multithreading)
::osl::MutexGuard aGuard( theCJKOptionsMutex::get() );
pImpl = pCJKOptions.lock();
pImpl = g_pCJKOptions.lock();
if ( !pImpl )
{
pImpl = std::make_shared<SvtCJKOptions_Impl>();
pCJKOptions = pImpl;
g_pCJKOptions = pImpl;
ItemHolder2::holdConfigItem(E_CJKOPTIONS);
}
......
......@@ -372,21 +372,25 @@ void SvtCTLOptions_Impl::SetCTLTextNumerals( SvtCTLOptions::TextNumerals _eNumer
NotifyListeners(0);
}
}
// global
std::weak_ptr<SvtCTLOptions_Impl> pCTLOptions;
namespace { struct CTLMutex : public rtl::Static< osl::Mutex, CTLMutex > {}; }
namespace {
// global
std::weak_ptr<SvtCTLOptions_Impl> g_pCTLOptions;
struct CTLMutex : public rtl::Static< osl::Mutex, CTLMutex > {};
}
SvtCTLOptions::SvtCTLOptions( bool bDontLoad )
{
// Global access, must be guarded (multithreading)
::osl::MutexGuard aGuard( CTLMutex::get() );
m_pImpl = pCTLOptions.lock();
m_pImpl = g_pCTLOptions.lock();
if ( !m_pImpl )
{
m_pImpl = std::make_shared<SvtCTLOptions_Impl>();
pCTLOptions = m_pImpl;
g_pCTLOptions = m_pImpl;
ItemHolder2::holdConfigItem(E_CTLOPTIONS);
}
......
......@@ -315,18 +315,22 @@ Sequence< OUString > SvtMenuOptions_Impl::impl_GetPropertyNames()
return seqPropertyNames;
}
std::weak_ptr<SvtMenuOptions_Impl> m_pMenuOptions;
namespace {
std::weak_ptr<SvtMenuOptions_Impl> g_pMenuOptions;
}
SvtMenuOptions::SvtMenuOptions()
{
// Global access, must be guarded (multithreading!).
MutexGuard aGuard( GetOwnStaticMutex() );
m_pImpl = m_pMenuOptions.lock();
m_pImpl = g_pMenuOptions.lock();
if( !m_pImpl )
{
m_pImpl = std::make_shared<SvtMenuOptions_Impl>();
m_pMenuOptions = m_pImpl;
g_pMenuOptions = m_pImpl;
svtools::ItemHolder2::holdConfigItem(E_MENUOPTIONS);
}
}
......
......@@ -643,18 +643,22 @@ Sequence< OUString > SvtMiscOptions_Impl::GetPropertyNames()
return seqPropertyNames;
}
std::weak_ptr<SvtMiscOptions_Impl> m_pMiscOptions;
namespace {
std::weak_ptr<SvtMiscOptions_Impl> g_pMiscOptions;
}
SvtMiscOptions::SvtMiscOptions()
{
// Global access, must be guarded (multithreading!).
MutexGuard aGuard( GetInitMutex() );
m_pImpl = m_pMiscOptions.lock();
m_pImpl = g_pMiscOptions.lock();
if( !m_pImpl )
{
m_pImpl = std::make_shared<SvtMiscOptions_Impl>();
m_pMiscOptions = m_pImpl;
g_pMiscOptions = m_pImpl;
svtools::ItemHolder2::holdConfigItem(E_MISCOPTIONS);
}
}
......
......@@ -286,18 +286,22 @@ Sequence< OUString > SvtCommandOptions_Impl::impl_GetPropertyNames()
return lDisabledItems;
}
std::weak_ptr<SvtCommandOptions_Impl> m_pCommandOptions;
namespace {
std::weak_ptr<SvtCommandOptions_Impl> g_pCommandOptions;
}
SvtCommandOptions::SvtCommandOptions()
{
// Global access, must be guarded (multithreading!).
MutexGuard aGuard( GetOwnStaticMutex() );
m_pImpl = m_pCommandOptions.lock();
m_pImpl = g_pCommandOptions.lock();
if( !m_pImpl )
{
m_pImpl = std::make_shared<SvtCommandOptions_Impl>();
m_pCommandOptions = m_pImpl;
g_pCommandOptions = m_pImpl;
ItemHolder1::holdConfigItem(E_CMDOPTIONS);
}
}
......
......@@ -104,7 +104,11 @@ private:
// global ----------------------------------------------------------------
std::weak_ptr<SvtDefaultOptions_Impl> pOptions;
namespace {
std::weak_ptr<SvtDefaultOptions_Impl> g_pOptions;
}
typedef OUString SvtDefaultOptions_Impl:: *PathStrPtr;
......@@ -326,11 +330,11 @@ SvtDefaultOptions::SvtDefaultOptions()
{
// Global access, must be guarded (multithreading)
::osl::MutexGuard aGuard( lclMutex::get() );
pImpl = pOptions.lock();
pImpl = g_pOptions.lock();
if ( !pImpl )
{
pImpl = std::make_shared<SvtDefaultOptions_Impl>();
pOptions = pImpl;
g_pOptions = pImpl;
ItemHolder1::holdConfigItem(E_DEFAULTOPTIONS);
}
}
......
......@@ -239,18 +239,22 @@ Sequence< OUString > SvtExtendedSecurityOptions_Impl::GetPropertyNames()
return seqPropertyNames;
}
std::weak_ptr<SvtExtendedSecurityOptions_Impl> m_pExtendedSecurityOptions;
namespace {
std::weak_ptr<SvtExtendedSecurityOptions_Impl> g_pExtendedSecurityOptions;
}
SvtExtendedSecurityOptions::SvtExtendedSecurityOptions()
{
// Global access, must be guarded (multithreading!).
MutexGuard aGuard( GetInitMutex() );
m_pImpl = m_pExtendedSecurityOptions.lock();
m_pImpl = g_pExtendedSecurityOptions.lock();
if( !m_pImpl )
{
m_pImpl = std::make_shared<SvtExtendedSecurityOptions_Impl>();
m_pExtendedSecurityOptions = m_pImpl;
g_pExtendedSecurityOptions = m_pImpl;
ItemHolder1::holdConfigItem(E_EXTENDEDSECURITYOPTIONS);
}
}
......
......@@ -243,18 +243,22 @@ Sequence< OUString > SvtFontOptions_Impl::impl_GetPropertyNames()
return seqPropertyNames;
}
std::weak_ptr<SvtFontOptions_Impl> m_pFontOptions;
namespace {
std::weak_ptr<SvtFontOptions_Impl> g_pFontOptions;
}
SvtFontOptions::SvtFontOptions()
{
// Global access, must be guarded (multithreading!).
MutexGuard aGuard( impl_GetOwnStaticMutex() );
m_pImpl = m_pFontOptions.lock();
m_pImpl = g_pFontOptions.lock();
if( !m_pImpl )
{
m_pImpl = std::make_shared<SvtFontOptions_Impl>();
m_pFontOptions = m_pImpl;
g_pFontOptions = m_pImpl;
ItemHolder1::holdConfigItem(E_FONTOPTIONS);
}
}
......
......@@ -523,17 +523,21 @@ void SvtHistoryOptions_Impl::DeleteItem(EHistoryType eHistory, const OUString& s
}
}
std::weak_ptr<SvtHistoryOptions_Impl> m_pHistoryOptions;
namespace {
std::weak_ptr<SvtHistoryOptions_Impl> g_pHistoryOptions;
}
SvtHistoryOptions::SvtHistoryOptions()
{
MutexGuard aGuard(theHistoryOptionsMutex::get());
m_pImpl = m_pHistoryOptions.lock();
m_pImpl = g_pHistoryOptions.lock();
if( !m_pImpl )
{
m_pImpl = std::make_shared<SvtHistoryOptions_Impl>();
m_pHistoryOptions = m_pImpl;
g_pHistoryOptions = m_pImpl;
ItemHolder1::holdConfigItem(E_HISTORYOPTIONS);
}
}
......
......@@ -218,18 +218,22 @@ Sequence< OUString > SvtLocalisationOptions_Impl::GetPropertyNames()
return seqPropertyNames;
}
std::weak_ptr<SvtLocalisationOptions_Impl> m_pLocalisationOptions;
namespace {
std::weak_ptr<SvtLocalisationOptions_Impl> g_pLocalisationOptions;
}
SvtLocalisationOptions::SvtLocalisationOptions()
{
// Global access, must be guarded (multithreading!).
MutexGuard aGuard( GetOwnStaticMutex() );
m_pImpl = m_pLocalisationOptions.lock();
m_pImpl = g_pLocalisationOptions.lock();
if( !m_pImpl )
{
m_pImpl = std::make_shared<SvtLocalisationOptions_Impl>();
m_pLocalisationOptions = m_pImpl;
g_pLocalisationOptions = m_pImpl;
ItemHolder1::holdConfigItem(E_LOCALISATIONOPTIONS);
}
}
......
......@@ -33,7 +33,7 @@ namespace utl
{
class SfxMiscCfg;
std::weak_ptr<SfxMiscCfg> m_pOptions;
std::weak_ptr<SfxMiscCfg> g_pOptions;
class SfxMiscCfg : public utl::ConfigItem
{
......@@ -186,11 +186,11 @@ MiscCfg::MiscCfg( )
{
// Global access, must be guarded (multithreading)
::osl::MutexGuard aGuard( LocalSingleton::get() );
m_pImpl = m_pOptions.lock();
m_pImpl = g_pOptions.lock();
if ( !m_pImpl )
{
m_pImpl = std::make_shared<SfxMiscCfg>();
m_pOptions = m_pImpl;
g_pOptions = m_pImpl;
ItemHolder1::holdConfigItem(E_MISCCFG);
}
......
......@@ -162,7 +162,7 @@ class SvtPathOptions_Impl
// global ----------------------------------------------------------------
static std::weak_ptr<SvtPathOptions_Impl> pOptions;
static std::weak_ptr<SvtPathOptions_Impl> g_pOptions;
// functions -------------------------------------------------------------
struct PropertyStruct
......@@ -446,11 +446,11 @@ SvtPathOptions::SvtPathOptions()
{
// Global access, must be guarded (multithreading)
::osl::MutexGuard aGuard( lclMutex::get() );
pImpl = pOptions.lock();
pImpl = g_pOptions.lock();
if ( !pImpl )
{
pImpl = std::make_shared<SvtPathOptions_Impl>();
pOptions = pImpl;
g_pOptions = pImpl;
ItemHolder1::holdConfigItem(E_PATHOPTIONS);
}
}
......
......@@ -221,18 +221,18 @@ Sequence< OUString > SvtPrintWarningOptions_Impl::impl_GetPropertyNames()
return seqPropertyNames;
}
std::weak_ptr<SvtPrintWarningOptions_Impl> m_pPrintWarningOptions;
std::weak_ptr<SvtPrintWarningOptions_Impl> g_pPrintWarningOptions;
SvtPrintWarningOptions::SvtPrintWarningOptions()
{
// Global access, must be guarded (multithreading!).
MutexGuard aGuard( GetOwnStaticMutex() );
m_pImpl = m_pPrintWarningOptions.lock();
m_pImpl = g_pPrintWarningOptions.lock();
if( !m_pImpl )
{
m_pImpl = std::make_shared<SvtPrintWarningOptions_Impl>();
m_pPrintWarningOptions = m_pImpl;
g_pPrintWarningOptions = m_pImpl;
ItemHolder1::holdConfigItem(E_PRINTWARNINGOPTIONS);
}
}
......
......@@ -930,18 +930,22 @@ Sequence< OUString > SvtSecurityOptions_Impl::GetPropertyNames()
return seqPropertyNames;
}
std::weak_ptr<SvtSecurityOptions_Impl> m_pSecurityOptions;
namespace {
std::weak_ptr<SvtSecurityOptions_Impl> g_pSecurityOptions;
}
SvtSecurityOptions::SvtSecurityOptions()
{
// Global access, must be guarded (multithreading!).
MutexGuard aGuard( GetInitMutex() );
m_pImpl = m_pSecurityOptions.lock();
m_pImpl = g_pSecurityOptions.lock();
if( !m_pImpl )
{
m_pImpl = std::make_shared<SvtSecurityOptions_Impl>();
m_pSecurityOptions = m_pImpl;
g_pSecurityOptions = m_pImpl;
ItemHolder1::holdConfigItem(E_SECURITYOPTIONS);
}
......
......@@ -34,7 +34,11 @@
using namespace osl;
using namespace com::sun::star;
std::weak_ptr<SvtSysLocale_Impl> pSysLocale;
namespace {
std::weak_ptr<SvtSysLocale_Impl> g_pSysLocale;
}
class SvtSysLocale_Impl : public utl::ConfigurationListener
{
......@@ -113,11 +117,11 @@ void SvtSysLocale_Impl::setDateAcceptancePatternsConfig()
SvtSysLocale::SvtSysLocale()
{
MutexGuard aGuard( GetMutex() );
pImpl = pSysLocale.lock();
pImpl = g_pSysLocale.lock();
if ( !pImpl )
{
pImpl = std::make_shared<SvtSysLocale_Impl>();
pSysLocale = pImpl;
g_pSysLocale = pImpl;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment