diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-13 13:33:08 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-13 15:35:36 +0200 |
commit | 9753428dfc2bf038188c9a59af7fd2d789b46517 (patch) | |
tree | 923a3d1888dbadc38436de76b9cad343be5380fe /framework | |
parent | 53b8fcbd3f81903b171fd59478abf0283c6feb24 (diff) |
rtl::Static -> thread-safe static local
Change-Id: If5b7181fb1bb3f3f21ec3742680e5a3e12b21b73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120431
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/source/accelerators/keymapping.cxx | 10 | ||||
-rw-r--r-- | framework/source/helper/statusindicatorfactory.cxx | 9 | ||||
-rw-r--r-- | framework/source/layoutmanager/layoutmanager.cxx | 12 | ||||
-rw-r--r-- | framework/source/services/desktop.cxx | 14 | ||||
-rw-r--r-- | framework/source/uiconfiguration/globalsettings.cxx | 13 | ||||
-rw-r--r-- | framework/source/uiconfiguration/imagemanagerimpl.cxx | 10 |
6 files changed, 14 insertions, 54 deletions
diff --git a/framework/source/accelerators/keymapping.cxx b/framework/source/accelerators/keymapping.cxx index 5f78d6dd65b0..1a5648c8d43a 100644 --- a/framework/source/accelerators/keymapping.cxx +++ b/framework/source/accelerators/keymapping.cxx @@ -21,7 +21,6 @@ #include <com/sun/star/awt/Key.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> -#include <rtl/instance.hxx> namespace framework { @@ -154,14 +153,9 @@ KeyMapping::KeyMapping() } } -namespace { - -struct Instance: public rtl::Static<KeyMapping, Instance> {}; - -} - KeyMapping & KeyMapping::get() { - return Instance::get(); + static KeyMapping KEYS; + return KEYS; } sal_uInt16 KeyMapping::mapIdentifierToCode(const OUString& sIdentifier) diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx index 45c96b373f1a..65cf6141d5ae 100644 --- a/framework/source/helper/statusindicatorfactory.cxx +++ b/framework/source/helper/statusindicatorfactory.cxx @@ -42,12 +42,6 @@ namespace framework{ sal_Int32 StatusIndicatorFactory::m_nInReschedule = 0; ///< static counter for rescheduling -namespace { - -struct RescheduleLock: public rtl::Static<osl::Mutex, RescheduleLock> {}; ///< mutex to guard the m_nInReschedule - -} - constexpr OUStringLiteral PROGRESS_RESOURCE = u"private:resource/progressbar/progressbar"; StatusIndicatorFactory::StatusIndicatorFactory(const css::uno::Reference< css::uno::XComponentContext >& xContext) @@ -518,8 +512,9 @@ void StatusIndicatorFactory::impl_reschedule(bool bForce) if (!bReschedule) return; + static osl::Mutex rescheduleLock; // SAFE -> - osl::ResettableMutexGuard aRescheduleGuard(RescheduleLock::get()); + osl::ResettableMutexGuard aRescheduleGuard(rescheduleLock); if (m_nInReschedule != 0) return; diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 4d821b4e08ae..b46db52906ff 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -58,7 +58,6 @@ #include <toolkit/helper/vclunohelper.hxx> #include <toolkit/awt/vclxmenu.hxx> #include <comphelper/uno3.hxx> -#include <rtl/instance.hxx> #include <officecfg/Office/Compatibility.hxx> #include <rtl/ref.hxx> @@ -3066,18 +3065,11 @@ namespace detail ::cppu::OPropertyArrayHelper& getHelper() { return *m_pInfoHelper; } }; } -namespace -{ - struct theInfoHelper : - public rtl::StaticWithArg< detail::InfoHelperBuilder, LayoutManager, - theInfoHelper > - { - }; -} ::cppu::IPropertyArrayHelper& SAL_CALL LayoutManager::getInfoHelper() { - return theInfoHelper::get(*this).getHelper(); + static detail::InfoHelperBuilder INFO(*this); + return INFO.getHelper(); } uno::Reference< beans::XPropertySetInfo > SAL_CALL LayoutManager::getPropertySetInfo() diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index ea2f0cac77f5..c369998365fe 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -51,7 +51,6 @@ #include <comphelper/sequence.hxx> #include <comphelper/lok.hxx> #include <cppuhelper/supportsservice.hxx> -#include <rtl/instance.hxx> #include <vcl/svapp.hxx> #include <desktop/crashreport.hxx> #include <vcl/scheduler.hxx> @@ -1441,11 +1440,9 @@ void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue , ::cppu::IPropertyArrayHelper& SAL_CALL Desktop::getInfoHelper() { - struct Static: - public rtl::StaticWithInit<cppu::OPropertyArrayHelper, Static> - { - cppu::OPropertyArrayHelper operator ()() { - return { + static cppu::OPropertyArrayHelper HELPER = + [&] () { + return cppu::OPropertyArrayHelper { {{"ActiveFrame", PropHandle::ActiveFrame, cppu::UnoType<css::lang::XComponent>::get(), (css::beans::PropertyAttribute::TRANSIENT @@ -1464,9 +1461,8 @@ void SAL_CALL Desktop::getFastPropertyValue( css::uno::Any& aValue , {"Title", PropHandle::Title, cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::TRANSIENT}}, true}; - } - }; - return Static::get(); + }(); + return HELPER; } /*-************************************************************************************************************ diff --git a/framework/source/uiconfiguration/globalsettings.cxx b/framework/source/uiconfiguration/globalsettings.cxx index 2727c2bb24cb..5efaa204274b 100644 --- a/framework/source/uiconfiguration/globalsettings.cxx +++ b/framework/source/uiconfiguration/globalsettings.cxx @@ -25,7 +25,6 @@ #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XEventListener.hpp> -#include <rtl/instance.hxx> #include <rtl/ref.hxx> #include <comphelper/propertysequence.hxx> #include <cppuhelper/implbase.hxx> @@ -222,19 +221,9 @@ void GlobalSettings_Access::impl_initConfigAccess() // global class -namespace { - -struct mutexGlobalSettings : public rtl::Static< osl::Mutex, mutexGlobalSettings > {}; - -} - -static rtl::Reference<GlobalSettings_Access> pStaticSettings; - static GlobalSettings_Access* GetGlobalSettings( const css::uno::Reference< css::uno::XComponentContext >& rxContext ) { - osl::MutexGuard aGuard(mutexGlobalSettings::get()); - if ( !pStaticSettings ) - pStaticSettings = new GlobalSettings_Access( rxContext ); + static rtl::Reference<GlobalSettings_Access> pStaticSettings = new GlobalSettings_Access( rxContext ); return pStaticSettings.get(); } diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index 04ec4db065e1..f479063b4bfc 100644 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -44,7 +44,6 @@ #include <unotools/ucbstreamhelper.hxx> #include <vcl/filter/PngImageReader.hxx> #include <vcl/pngwrite.hxx> -#include <rtl/instance.hxx> #include <memory> using ::com::sun::star::uno::Sequence; @@ -86,15 +85,10 @@ namespace framework static GlobalImageList* pGlobalImageList = nullptr; -namespace -{ - class theGlobalImageListMutex - : public rtl::Static<osl::Mutex, theGlobalImageListMutex> {}; -} - static osl::Mutex& getGlobalImageListMutex() { - return theGlobalImageListMutex::get(); + static osl::Mutex mutex; + return mutex; } static GlobalImageList* getGlobalImageList( const uno::Reference< uno::XComponentContext >& rxContext ) |