summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-08-17 11:38:31 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-17 22:40:40 +0200
commit4dc40659044566280c202e26cab97d682ae6ab54 (patch)
treed97f0e436aac00a5f52624959b0662eb21a534a0 /basic
parent889df64fbb9534491b76140d63b4340091c763e4 (diff)
rtl::Static -> thread-safe static local
Change-Id: I9f8fe250813f4f376dc46c6f3d7e25e90fdbb50e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120566 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/basmgr/vbahelper.cxx7
-rw-r--r--basic/source/classes/global.cxx5
-rw-r--r--basic/source/classes/sb.cxx19
-rw-r--r--basic/source/classes/sbunoobj.cxx14
-rw-r--r--basic/source/comp/token.cxx7
-rw-r--r--basic/source/runtime/runtime.cxx19
6 files changed, 31 insertions, 40 deletions
diff --git a/basic/source/basmgr/vbahelper.cxx b/basic/source/basmgr/vbahelper.cxx
index 83165374a8f1..7fa101a8259e 100644
--- a/basic/source/basmgr/vbahelper.cxx
+++ b/basic/source/basmgr/vbahelper.cxx
@@ -27,7 +27,6 @@
#include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
#include <comphelper/processfactory.hxx>
-#include <rtl/instance.hxx>
namespace basic::vba {
@@ -145,8 +144,6 @@ struct CurrDirPool
std::map< OUString, OUString > maCurrDirs;
};
-struct StaticCurrDirPool : public ::rtl::Static< CurrDirPool, StaticCurrDirPool > {};
-
} // namespace
@@ -167,7 +164,9 @@ void registerCurrentDirectory( const uno::Reference< frame::XModel >& rxModel, c
if( rPath.isEmpty() )
return;
- CurrDirPool& rPool = StaticCurrDirPool::get();
+ static CurrDirPool StaticCurrDirPool;
+
+ CurrDirPool& rPool = StaticCurrDirPool;
::osl::MutexGuard aGuard( rPool.maMutex );
try
{
diff --git a/basic/source/classes/global.cxx b/basic/source/classes/global.cxx
index 1e72e242d94b..d2e3622b4d6f 100644
--- a/basic/source/classes/global.cxx
+++ b/basic/source/classes/global.cxx
@@ -10,7 +10,6 @@
#include <comphelper/processfactory.hxx>
#include <i18nlangtag/lang.h>
#include <i18nutil/transliteration.hxx>
-#include <rtl/instance.hxx>
#include <unotools/transliterationwrapper.hxx>
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
@@ -35,12 +34,12 @@ namespace
utl::TransliterationWrapper& getTransliteration() { return m_aTransliteration; }
};
- class theTransliterationWrapper : public rtl::Static<lclTransliterationWrapper, theTransliterationWrapper> {};
}
utl::TransliterationWrapper& SbGlobal::GetTransliteration()
{
- return theTransliterationWrapper::get().getTransliteration();
+ static lclTransliterationWrapper theTransliterationWrapper;
+ return theTransliterationWrapper.getTransliteration();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index e4ee5b508451..f0ab981d62a5 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -177,31 +177,31 @@ namespace {
typedef ::rtl::Reference< DocBasicItem > DocBasicItemRef;
-class GaDocBasicItems : public rtl::Static<std::unordered_map< const StarBASIC *, DocBasicItemRef >,GaDocBasicItems> {};
+std::unordered_map< const StarBASIC *, DocBasicItemRef > gaDocBasicItems;
const DocBasicItem* lclFindDocBasicItem( const StarBASIC* pDocBasic )
{
- auto it = GaDocBasicItems::get().find( pDocBasic );
- auto end = GaDocBasicItems::get().end();
+ auto it = gaDocBasicItems.find( pDocBasic );
+ auto end = gaDocBasicItems.end();
return (it != end) ? it->second.get() : nullptr;
}
void lclInsertDocBasicItem( StarBASIC& rDocBasic )
{
- DocBasicItemRef& rxDocBasicItem = GaDocBasicItems::get()[ &rDocBasic ];
+ DocBasicItemRef& rxDocBasicItem = gaDocBasicItems[ &rDocBasic ];
rxDocBasicItem.set( new DocBasicItem( rDocBasic ) );
rxDocBasicItem->startListening();
}
void lclRemoveDocBasicItem( StarBASIC& rDocBasic )
{
- auto it = GaDocBasicItems::get().find( &rDocBasic );
- if( it != GaDocBasicItems::get().end() )
+ auto it = gaDocBasicItems.find( &rDocBasic );
+ if( it != gaDocBasicItems.end() )
{
it->second->stopListening();
- GaDocBasicItems::get().erase( it );
+ gaDocBasicItems.erase( it );
}
- for( auto& rEntry : GaDocBasicItems::get() )
+ for( auto& rEntry : gaDocBasicItems )
{
rEntry.second->clearDependingVarsOnDelete( rDocBasic );
}
@@ -1914,8 +1914,7 @@ Reference< frame::XModel > StarBASIC::GetModelFromBasic( SbxObject* pBasic )
void StarBASIC::DetachAllDocBasicItems()
{
- std::unordered_map< const StarBASIC *, DocBasicItemRef >& rItems = GaDocBasicItems::get();
- for (auto const& item : rItems)
+ for (auto const& item : gaDocBasicItems)
{
DocBasicItemRef xItem = item.second;
xItem->setDisposed(true);
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index edf112eca9e3..4131980848ba 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -449,30 +449,28 @@ typedef std::vector< ObjectItem > NativeObjectWrapperVector;
namespace {
-class GaNativeObjectWrapperVector : public rtl::Static<NativeObjectWrapperVector, GaNativeObjectWrapperVector> {};
+NativeObjectWrapperVector gaNativeObjectWrapperVector;
}
void clearNativeObjectWrapperVector()
{
- GaNativeObjectWrapperVector::get().clear();
+ gaNativeObjectWrapperVector.clear();
}
static sal_uInt32 lcl_registerNativeObjectWrapper( SbxObject* pNativeObj )
{
- NativeObjectWrapperVector &rNativeObjectWrapperVector = GaNativeObjectWrapperVector::get();
- sal_uInt32 nIndex = rNativeObjectWrapperVector.size();
- rNativeObjectWrapperVector.emplace_back( pNativeObj );
+ sal_uInt32 nIndex = gaNativeObjectWrapperVector.size();
+ gaNativeObjectWrapperVector.emplace_back( pNativeObj );
return nIndex;
}
static SbxObject* lcl_getNativeObject( sal_uInt32 nIndex )
{
SbxObjectRef xRetObj;
- NativeObjectWrapperVector &rNativeObjectWrapperVector = GaNativeObjectWrapperVector::get();
- if( nIndex < rNativeObjectWrapperVector.size() )
+ if( nIndex < gaNativeObjectWrapperVector.size() )
{
- ObjectItem& rItem = rNativeObjectWrapperVector[ nIndex ];
+ ObjectItem& rItem = gaNativeObjectWrapperVector[ nIndex ];
xRetObj = rItem.m_xNativeObj;
}
return xRetObj.get();
diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx
index bf47a1b2aaa8..9be47bf41ba1 100644
--- a/basic/source/comp/token.cxx
+++ b/basic/source/comp/token.cxx
@@ -21,7 +21,6 @@
#include <array>
#include <basic/sberrors.hxx>
-#include <rtl/instance.hxx>
#include <sal/macros.h>
#include <basiccharclass.hxx>
#include <token.hxx>
@@ -192,8 +191,6 @@ public:
{ return m_pTokenCanBeLabelTab[eTok]; }
};
-class StaticTokenLabelInfo: public ::rtl::Static< TokenLabelInfo, StaticTokenLabelInfo >{};
-
}
// #i109076
@@ -546,7 +543,9 @@ special:
bool SbiTokenizer::MayBeLabel( bool bNeedsColon )
{
- if( eCurTok == SYMBOL || StaticTokenLabelInfo::get().canTokenBeLabel( eCurTok ) )
+ static TokenLabelInfo gaStaticTokenLabelInfo;
+
+ if( eCurTok == SYMBOL || gaStaticTokenLabelInfo.canTokenBeLabel( eCurTok ) )
{
return !bNeedsColon || DoesColonFollow();
}
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index e88065225793..b100e93cac20 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -1769,17 +1769,16 @@ typedef std::unordered_map< SbxVariable*, DimAsNewRecoverItem,
namespace {
-class GaDimAsNewRecoverHash : public rtl::Static<DimAsNewRecoverHash, GaDimAsNewRecoverHash> {};
+DimAsNewRecoverHash gaDimAsNewRecoverHash;
}
void removeDimAsNewRecoverItem( SbxVariable* pVar )
{
- DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
- DimAsNewRecoverHash::iterator it = rDimAsNewRecoverHash.find( pVar );
- if( it != rDimAsNewRecoverHash.end() )
+ DimAsNewRecoverHash::iterator it = gaDimAsNewRecoverHash.find( pVar );
+ if( it != gaDimAsNewRecoverHash.end() )
{
- rDimAsNewRecoverHash.erase( it );
+ gaDimAsNewRecoverHash.erase( it );
}
}
@@ -1950,9 +1949,8 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
if( xPrevVarObj.is() )
{
// Object is overwritten with NULL, instantiate init object
- DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
- DimAsNewRecoverHash::iterator it = rDimAsNewRecoverHash.find( refVar.get() );
- if( it != rDimAsNewRecoverHash.end() )
+ DimAsNewRecoverHash::iterator it = gaDimAsNewRecoverHash.find( refVar.get() );
+ if( it != gaDimAsNewRecoverHash.end() )
{
const DimAsNewRecoverItem& rItem = it->second;
if( rItem.m_pClassModule != nullptr )
@@ -1985,16 +1983,15 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
OUString aObjClass = pValObj->GetClassName();
SbClassModuleObject* pClassModuleObj = dynamic_cast<SbClassModuleObject*>( pValObjBase );
- DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get();
if( pClassModuleObj != nullptr )
{
SbModule* pClassModule = pClassModuleObj->getClassModule();
- rDimAsNewRecoverHash[refVar.get()] =
+ gaDimAsNewRecoverHash[refVar.get()] =
DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), pClassModule );
}
else if( aObjClass.equalsIgnoreAsciiCase( "Collection" ) )
{
- rDimAsNewRecoverHash[refVar.get()] =
+ gaDimAsNewRecoverHash[refVar.get()] =
DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), nullptr );
}
}