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 /filter | |
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 'filter')
-rw-r--r-- | filter/source/config/cache/basecontainer.cxx | 10 | ||||
-rw-r--r-- | filter/source/config/cache/contenthandlerfactory.cxx | 2 | ||||
-rw-r--r-- | filter/source/config/cache/filtercache.hxx | 3 | ||||
-rw-r--r-- | filter/source/config/cache/filterfactory.cxx | 10 | ||||
-rw-r--r-- | filter/source/config/cache/frameloaderfactory.cxx | 2 | ||||
-rw-r--r-- | filter/source/config/cache/typedetection.cxx | 20 | ||||
-rw-r--r-- | filter/source/xsltdialog/xmlfilterdialogcomponent.cxx | 40 |
7 files changed, 36 insertions, 51 deletions
diff --git a/filter/source/config/cache/basecontainer.cxx b/filter/source/config/cache/basecontainer.cxx index 4047f4df2719..023afd29415a 100644 --- a/filter/source/config/cache/basecontainer.cxx +++ b/filter/source/config/cache/basecontainer.cxx @@ -38,7 +38,7 @@ BaseContainer::BaseContainer() , m_eType() , m_lListener (m_aLock) { - TheFilterCache::get().load(FilterCache::E_CONTAINS_STANDARD); + GetTheFilterCache().load(FilterCache::E_CONTAINS_STANDARD); } @@ -93,7 +93,7 @@ void BaseContainer::impl_loadOnDemand() break; } - TheFilterCache::get().load(eRequiredState); + GetTheFilterCache().load(eRequiredState); // <- SAFE #endif } @@ -104,7 +104,7 @@ void BaseContainer::impl_initFlushMode() // SAFE -> osl::MutexGuard aLock(m_aLock); if (!m_pFlushCache) - m_pFlushCache = TheFilterCache::get().clone(); + m_pFlushCache = GetTheFilterCache().clone(); if (!m_pFlushCache) throw css::uno::RuntimeException( "Can not create write copy of internal used cache on demand.", static_cast< OWeakObject* >(this)); @@ -119,7 +119,7 @@ FilterCache* BaseContainer::impl_getWorkingCache() const if (m_pFlushCache) return m_pFlushCache.get(); else - return &TheFilterCache::get(); + return &GetTheFilterCache(); // <- SAFE } @@ -422,7 +422,7 @@ void SAL_CALL BaseContainer::flush() If the global cache gets this information via listener, we should remove this method! */ - TheFilterCache::get().takeOver(*m_pFlushCache); + GetTheFilterCache().takeOver(*m_pFlushCache); } catch(const css::uno::Exception& ex) { diff --git a/filter/source/config/cache/contenthandlerfactory.cxx b/filter/source/config/cache/contenthandlerfactory.cxx index a5140acdbed2..a3bf71cf22ed 100644 --- a/filter/source/config/cache/contenthandlerfactory.cxx +++ b/filter/source/config/cache/contenthandlerfactory.cxx @@ -55,7 +55,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL ContentHandlerFactory::crea // SAFE -> osl::MutexGuard aLock(m_aLock); - auto & cache = TheFilterCache::get(); + auto & cache = GetTheFilterCache(); // search handler on cache CacheItem aHandler = cache.getItem(FilterCache::E_CONTENTHANDLER, sHandler); diff --git a/filter/source/config/cache/filtercache.hxx b/filter/source/config/cache/filtercache.hxx index 66d07467f6f3..a0ef79c93931 100644 --- a/filter/source/config/cache/filtercache.hxx +++ b/filter/source/config/cache/filtercache.hxx @@ -29,7 +29,6 @@ #include <com/sun/star/uno/Reference.h> #include <com/sun/star/uno/Any.h> #include <comphelper/documentconstants.hxx> -#include <rtl/instance.hxx> #include <rtl/ref.hxx> #include <rtl/ustring.hxx> @@ -933,7 +932,7 @@ class FilterCache : public BaseLock static css::uno::Sequence< OUString > impl_convertFlagField2FlagNames(SfxFilterFlags nFlags); }; -struct TheFilterCache: public rtl::Static<FilterCache, TheFilterCache> {}; +FilterCache& GetTheFilterCache(); } // namespace filter::config diff --git a/filter/source/config/cache/filterfactory.cxx b/filter/source/config/cache/filterfactory.cxx index e499b4bad633..8832330d5a04 100644 --- a/filter/source/config/cache/filterfactory.cxx +++ b/filter/source/config/cache/filterfactory.cxx @@ -30,6 +30,12 @@ namespace filter::config{ +FilterCache& GetTheFilterCache() +{ + static FilterCache CACHE; + return CACHE; +} + /** @short define all possible parts of a filter query. @descr syntax: "<query>[:<param>[=<value>]]" @@ -73,7 +79,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FilterFactory::createInstan // SAFE -> osl::MutexGuard aLock(m_aLock); - auto & cache = TheFilterCache::get(); + auto & cache = GetTheFilterCache(); // search filter on cache CacheItem aFilter = cache.getItem(FilterCache::E_FILTER, sFilter); @@ -122,7 +128,7 @@ css::uno::Sequence< OUString > SAL_CALL FilterFactory::getAvailableServiceNames( std::vector<OUString> lUNOFilters; try { - lUNOFilters = TheFilterCache::get().getMatchingItemsByProps(FilterCache::E_FILTER, lIProps, lEProps); + lUNOFilters = GetTheFilterCache().getMatchingItemsByProps(FilterCache::E_FILTER, lIProps, lEProps); } catch(const css::uno::RuntimeException&) { throw; } diff --git a/filter/source/config/cache/frameloaderfactory.cxx b/filter/source/config/cache/frameloaderfactory.cxx index c7906b4acf1d..a3aef82e4c6c 100644 --- a/filter/source/config/cache/frameloaderfactory.cxx +++ b/filter/source/config/cache/frameloaderfactory.cxx @@ -53,7 +53,7 @@ css::uno::Reference< css::uno::XInterface > SAL_CALL FrameLoaderFactory::createI // SAFE -> osl::MutexGuard aLock(m_aLock); - auto & cache = TheFilterCache::get(); + auto & cache = GetTheFilterCache(); // search loader on cache CacheItem aLoader = cache.getItem(m_eType, sLoader); diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx index 34d0d49d5af9..1fd7cccc49ab 100644 --- a/filter/source/config/cache/typedetection.cxx +++ b/filter/source/config/cache/typedetection.cxx @@ -82,7 +82,7 @@ OUString SAL_CALL TypeDetection::queryTypeByURL(const OUString& sURL) // set std types as minimum requirement first! // Only in case no type was found for given URL, // use optional types too ... - auto & cache = TheFilterCache::get(); + auto & cache = GetTheFilterCache(); FlatDetection lFlatTypes; cache.detectFlatForURL(aURL, lFlatTypes); @@ -473,7 +473,7 @@ void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDes if (!sFilter.isEmpty()) return; - auto & cache = TheFilterCache::get(); + auto & cache = GetTheFilterCache(); // b) // check a preselected document service too. @@ -642,7 +642,7 @@ bool TypeDetection::impl_getPreselectionForType( { // SAFE -> -------------------------- osl::MutexGuard aLock(m_aLock); - aType = TheFilterCache::get().getItem(FilterCache::E_TYPE, sType); + aType = GetTheFilterCache().getItem(FilterCache::E_TYPE, sType); // <- SAFE -------------------------- } catch(const css::container::NoSuchElementException&) @@ -732,7 +732,7 @@ void TypeDetection::impl_getPreselectionForDocumentService( // Attention: For executing next lines of code, We must be sure that // all filters already loaded :-( // That can disturb our "load on demand feature". But we have no other chance! - auto & cache = TheFilterCache::get(); + auto & cache = GetTheFilterCache(); cache.load(FilterCache::E_CONTAINS_FILTERS); CacheItem lIProps; @@ -766,7 +766,7 @@ OUString TypeDetection::impl_getTypeFromFilter(const OUString& rFilterName) try { osl::MutexGuard aLock(m_aLock); - aFilter = TheFilterCache::get().getItem(FilterCache::E_FILTER, rFilterName); + aFilter = GetTheFilterCache().getItem(FilterCache::E_FILTER, rFilterName); } catch (const container::NoSuchElementException&) { @@ -788,7 +788,7 @@ void TypeDetection::impl_getAllFormatTypes( try { osl::MutexGuard aLock(m_aLock); - auto & cache = TheFilterCache::get(); + auto & cache = GetTheFilterCache(); cache.load(FilterCache::E_CONTAINS_FILTERS); aFilterNames = cache.getItemNames(FilterCache::E_FILTER); } @@ -813,7 +813,7 @@ void TypeDetection::impl_getAllFormatTypes( { // Get all types that match the URL alone. FlatDetection aFlatByURL; - TheFilterCache::get().detectFlatForURL(aParsedURL, aFlatByURL); + GetTheFilterCache().detectFlatForURL(aParsedURL, aFlatByURL); for (auto const& elem : aFlatByURL) { FlatDetection::iterator itPos = std::find_if(rFlatTypes.begin(), rFlatTypes.end(), FindByType(elem.sType)); @@ -900,7 +900,7 @@ OUString TypeDetection::impl_detectTypeFlatAndDeep( utl::MediaDescriptor& r { // SAFE -> ---------------------------------- osl::ClearableMutexGuard aLock(m_aLock); - CacheItem aType = TheFilterCache::get().getItem(FilterCache::E_TYPE, sFlatType); + CacheItem aType = GetTheFilterCache().getItem(FilterCache::E_TYPE, sFlatType); aLock.clear(); OUString sDetectService; @@ -1155,7 +1155,7 @@ bool TypeDetection::impl_validateAndSetTypeOnDescriptor( utl::MediaDescript // SAFE -> { osl::MutexGuard aLock(m_aLock); - if (TheFilterCache::get().hasItem(FilterCache::E_TYPE, sType)) + if (GetTheFilterCache().hasItem(FilterCache::E_TYPE, sType)) { rDescriptor[utl::MediaDescriptor::PROP_TYPENAME()] <<= sType; return true; @@ -1177,7 +1177,7 @@ bool TypeDetection::impl_validateAndSetFilterOnDescriptor( utl::MediaDescri // SAFE -> osl::ClearableMutexGuard aLock(m_aLock); - auto & cache = TheFilterCache::get(); + auto & cache = GetTheFilterCache(); CacheItem aFilter = cache.getItem(FilterCache::E_FILTER, sFilter); OUString sType; aFilter[PROPNAME_TYPE] >>= sType; diff --git a/filter/source/xsltdialog/xmlfilterdialogcomponent.cxx b/filter/source/xsltdialog/xmlfilterdialogcomponent.cxx index ec7b04b964fd..095e00e6ab0b 100644 --- a/filter/source/xsltdialog/xmlfilterdialogcomponent.cxx +++ b/filter/source/xsltdialog/xmlfilterdialogcomponent.cxx @@ -31,7 +31,6 @@ #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <vcl/svapp.hxx> -#include <rtl/instance.hxx> #include "xmlfiltersettingsdialog.hxx" @@ -162,42 +161,23 @@ OUString SAL_CALL XMLFilterDialogComponent::getImplementationName() return "com.sun.star.comp.ui.XSLTFilterDialog"; } -namespace { struct lcl_ImplId : public rtl::Static< ::cppu::OImplementationId, lcl_ImplId > {}; } - Sequence< sal_Int8 > SAL_CALL XMLFilterDialogComponent::getImplementationId() { - return css::uno::Sequence<sal_Int8>(); + static ::cppu::OImplementationId implId; + return implId.getImplementationId(); } -namespace -{ - class DialogComponentTypes - { - private: - OTypeCollection m_aTypes; - public: - DialogComponentTypes() : - m_aTypes( - cppu::UnoType<XComponent>::get(), - cppu::UnoType<XTypeProvider>::get(), - cppu::UnoType<XAggregation>::get(), - cppu::UnoType<XWeak>::get(), - cppu::UnoType<XServiceInfo>::get(), - cppu::UnoType<XInitialization>::get(), - cppu::UnoType<XTerminateListener>::get(), - cppu::UnoType<css::ui::dialogs::XExecutableDialog>::get()) - { - } - OTypeCollection& getTypeCollection() { return m_aTypes; } - }; - - struct theDialogComponentTypes : rtl::Static<DialogComponentTypes, theDialogComponentTypes> {}; -} - Sequence< Type > XMLFilterDialogComponent::getTypes() { - return theDialogComponentTypes::get().getTypeCollection().getTypes(); + return { cppu::UnoType<XComponent>::get(), + cppu::UnoType<XTypeProvider>::get(), + cppu::UnoType<XAggregation>::get(), + cppu::UnoType<XWeak>::get(), + cppu::UnoType<XServiceInfo>::get(), + cppu::UnoType<XInitialization>::get(), + cppu::UnoType<XTerminateListener>::get(), + cppu::UnoType<css::ui::dialogs::XExecutableDialog>::get() }; } Sequence< OUString > SAL_CALL XMLFilterDialogComponent::getSupportedServiceNames() |