summaryrefslogtreecommitdiff
path: root/basic/source/classes
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/source/classes
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/source/classes')
-rw-r--r--basic/source/classes/global.cxx5
-rw-r--r--basic/source/classes/sb.cxx19
-rw-r--r--basic/source/classes/sbunoobj.cxx14
3 files changed, 17 insertions, 21 deletions
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();