summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2016-05-29 20:52:09 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-06-16 06:49:59 +0000
commit94d2b31d984382ba76c623236f6daf678204844a (patch)
tree992ff39990517217dcb7ee9df6fc6720192b0760 /unotools
parenta25d1a111150288b066351dfe11f75e5e4f81cfb (diff)
tdf#89329: use shared_ptr for pImpl in pathoptions
Change-Id: Id932a0886f0a8a3cb05a3d0474e29a2e0b84ad4e Reviewed-on: https://gerrit.libreoffice.org/25630 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/pathoptions.cxx121
1 files changed, 59 insertions, 62 deletions
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index 2a2c14bfff14..28632caba4c4 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -162,8 +162,7 @@ class SvtPathOptions_Impl
// global ----------------------------------------------------------------
-static SvtPathOptions_Impl* pOptions = nullptr;
-static sal_Int32 nRefCount = 0;
+static std::weak_ptr<SvtPathOptions_Impl> pOptions;
// functions -------------------------------------------------------------
struct PropertyStruct
@@ -447,273 +446,271 @@ SvtPathOptions::SvtPathOptions()
{
// Global access, must be guarded (multithreading)
::osl::MutexGuard aGuard( lclMutex::get() );
- if ( !pOptions )
+ pImpl = pOptions.lock();
+ if ( !pImpl )
{
- pOptions = new SvtPathOptions_Impl;
+ pImpl = std::make_shared<SvtPathOptions_Impl>();
+ pOptions = pImpl;
ItemHolder1::holdConfigItem(E_PATHOPTIONS);
}
- ++nRefCount;
- pImp = pOptions;
}
SvtPathOptions::~SvtPathOptions()
{
// Global access, must be guarded (multithreading)
::osl::MutexGuard aGuard( lclMutex::get() );
- if ( !--nRefCount )
- {
- DELETEZ( pOptions );
- }
+
+ pImpl.reset();
}
const OUString& SvtPathOptions::GetAddinPath() const
{
- return pImp->GetAddinPath();
+ return pImpl->GetAddinPath();
}
const OUString& SvtPathOptions::GetAutoCorrectPath() const
{
- return pImp->GetAutoCorrectPath();
+ return pImpl->GetAutoCorrectPath();
}
const OUString& SvtPathOptions::GetAutoTextPath() const
{
- return pImp->GetAutoTextPath();
+ return pImpl->GetAutoTextPath();
}
const OUString& SvtPathOptions::GetBackupPath() const
{
- return pImp->GetBackupPath();
+ return pImpl->GetBackupPath();
}
const OUString& SvtPathOptions::GetBasicPath() const
{
- return pImp->GetBasicPath();
+ return pImpl->GetBasicPath();
}
const OUString& SvtPathOptions::GetBitmapPath() const
{
- return pImp->GetBitmapPath();
+ return pImpl->GetBitmapPath();
}
const OUString& SvtPathOptions::GetConfigPath() const
{
- return pImp->GetConfigPath();
+ return pImpl->GetConfigPath();
}
const OUString& SvtPathOptions::GetDictionaryPath() const
{
- return pImp->GetDictionaryPath();
+ return pImpl->GetDictionaryPath();
}
const OUString& SvtPathOptions::GetFavoritesPath() const
{
- return pImp->GetFavoritesPath();
+ return pImpl->GetFavoritesPath();
}
const OUString& SvtPathOptions::GetFilterPath() const
{
- return pImp->GetFilterPath();
+ return pImpl->GetFilterPath();
}
const OUString& SvtPathOptions::GetGalleryPath() const
{
- return pImp->GetGalleryPath();
+ return pImpl->GetGalleryPath();
}
const OUString& SvtPathOptions::GetGraphicPath() const
{
- return pImp->GetGraphicPath();
+ return pImpl->GetGraphicPath();
}
const OUString& SvtPathOptions::GetHelpPath() const
{
- return pImp->GetHelpPath();
+ return pImpl->GetHelpPath();
}
const OUString& SvtPathOptions::GetLinguisticPath() const
{
- return pImp->GetLinguisticPath();
+ return pImpl->GetLinguisticPath();
}
const OUString& SvtPathOptions::GetFingerprintPath() const
{
- return pImp->GetFingerprintPath();
+ return pImpl->GetFingerprintPath();
}
const OUString& SvtPathOptions::GetModulePath() const
{
- return pImp->GetModulePath();
+ return pImpl->GetModulePath();
}
const OUString& SvtPathOptions::GetPalettePath() const
{
- return pImp->GetPalettePath();
+ return pImpl->GetPalettePath();
}
const OUString& SvtPathOptions::GetPluginPath() const
{
- return pImp->GetPluginPath();
+ return pImpl->GetPluginPath();
}
const OUString& SvtPathOptions::GetStoragePath() const
{
- return pImp->GetStoragePath();
+ return pImpl->GetStoragePath();
}
const OUString& SvtPathOptions::GetTempPath() const
{
- return pImp->GetTempPath();
+ return pImpl->GetTempPath();
}
const OUString& SvtPathOptions::GetTemplatePath() const
{
- return pImp->GetTemplatePath();
+ return pImpl->GetTemplatePath();
}
const OUString& SvtPathOptions::GetUserConfigPath() const
{
- return pImp->GetUserConfigPath();
+ return pImpl->GetUserConfigPath();
}
const OUString& SvtPathOptions::GetUIConfigPath() const
{
- return pImp->GetUIConfigPath();
+ return pImpl->GetUIConfigPath();
}
const OUString& SvtPathOptions::GetWorkPath() const
{
- return pImp->GetWorkPath();
+ return pImpl->GetWorkPath();
}
const OUString& SvtPathOptions::GetClassificationPath() const
{
- return pImp->GetClassificationPath();
+ return pImpl->GetClassificationPath();
}
void SvtPathOptions::SetAddinPath( const OUString& rPath )
{
- pImp->SetAddinPath( rPath );
+ pImpl->SetAddinPath( rPath );
}
void SvtPathOptions::SetAutoCorrectPath( const OUString& rPath )
{
- pImp->SetAutoCorrectPath( rPath );
+ pImpl->SetAutoCorrectPath( rPath );
}
void SvtPathOptions::SetAutoTextPath( const OUString& rPath )
{
- pImp->SetAutoTextPath( rPath );
+ pImpl->SetAutoTextPath( rPath );
}
void SvtPathOptions::SetBackupPath( const OUString& rPath )
{
- pImp->SetBackupPath( rPath );
+ pImpl->SetBackupPath( rPath );
}
void SvtPathOptions::SetBasicPath( const OUString& rPath )
{
- pImp->SetBasicPath( rPath );
+ pImpl->SetBasicPath( rPath );
}
void SvtPathOptions::SetBitmapPath( const OUString& rPath )
{
- pImp->SetBitmapPath( rPath );
+ pImpl->SetBitmapPath( rPath );
}
void SvtPathOptions::SetConfigPath( const OUString& rPath )
{
- pImp->SetConfigPath( rPath );
+ pImpl->SetConfigPath( rPath );
}
void SvtPathOptions::SetDictionaryPath( const OUString& rPath )
{
- pImp->SetDictionaryPath( rPath );
+ pImpl->SetDictionaryPath( rPath );
}
void SvtPathOptions::SetFavoritesPath( const OUString& rPath )
{
- pImp->SetFavoritesPath( rPath );
+ pImpl->SetFavoritesPath( rPath );
}
void SvtPathOptions::SetFilterPath( const OUString& rPath )
{
- pImp->SetFilterPath( rPath );
+ pImpl->SetFilterPath( rPath );
}
void SvtPathOptions::SetGalleryPath( const OUString& rPath )
{
- pImp->SetGalleryPath( rPath );
+ pImpl->SetGalleryPath( rPath );
}
void SvtPathOptions::SetGraphicPath( const OUString& rPath )
{
- pImp->SetGraphicPath( rPath );
+ pImpl->SetGraphicPath( rPath );
}
void SvtPathOptions::SetHelpPath( const OUString& rPath )
{
- pImp->SetHelpPath( rPath );
+ pImpl->SetHelpPath( rPath );
}
void SvtPathOptions::SetLinguisticPath( const OUString& rPath )
{
- pImp->SetLinguisticPath( rPath );
+ pImpl->SetLinguisticPath( rPath );
}
void SvtPathOptions::SetModulePath( const OUString& rPath )
{
- pImp->SetModulePath( rPath );
+ pImpl->SetModulePath( rPath );
}
void SvtPathOptions::SetPalettePath( const OUString& rPath )
{
- pImp->SetPalettePath( rPath );
+ pImpl->SetPalettePath( rPath );
}
void SvtPathOptions::SetPluginPath( const OUString& rPath )
{
- pImp->SetPluginPath( rPath );
+ pImpl->SetPluginPath( rPath );
}
void SvtPathOptions::SetStoragePath( const OUString& rPath )
{
- pImp->SetStoragePath( rPath );
+ pImpl->SetStoragePath( rPath );
}
void SvtPathOptions::SetTempPath( const OUString& rPath )
{
- pImp->SetTempPath( rPath );
+ pImpl->SetTempPath( rPath );
}
void SvtPathOptions::SetTemplatePath( const OUString& rPath )
{
- pImp->SetTemplatePath( rPath );
+ pImpl->SetTemplatePath( rPath );
}
void SvtPathOptions::SetUserConfigPath( const OUString& rPath )
{
- pImp->SetUserConfigPath( rPath );
+ pImpl->SetUserConfigPath( rPath );
}
void SvtPathOptions::SetWorkPath( const OUString& rPath )
{
- pImp->SetWorkPath( rPath );
+ pImpl->SetWorkPath( rPath );
}
OUString SvtPathOptions::SubstituteVariable( const OUString& rVar ) const
{
- return pImp->SubstVar( rVar );
+ return pImpl->SubstVar( rVar );
}
OUString SvtPathOptions::ExpandMacros( const OUString& rPath ) const
{
- return pImp->ExpandMacros( rPath );
+ return pImpl->ExpandMacros( rPath );
}
OUString SvtPathOptions::UseVariable( const OUString& rPath ) const
{
- return pImp->UsePathVariables( rPath );
+ return pImpl->UsePathVariables( rPath );
}
bool SvtPathOptions::SearchFile( OUString& rIniFile, Paths ePath )
@@ -725,7 +722,7 @@ bool SvtPathOptions::SearchFile( OUString& rIniFile, Paths ePath )
return false;
}
- OUString aIniFile = pImp->SubstVar( rIniFile );
+ OUString aIniFile = pImpl->SubstVar( rIniFile );
bool bRet = false;
switch ( ePath )
@@ -846,7 +843,7 @@ bool SvtPathOptions::SearchFile( OUString& rIniFile, Paths ePath )
const LanguageTag& SvtPathOptions::GetLanguageTag() const
{
- return pImp->GetLanguageTag();
+ return pImpl->GetLanguageTag();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */