summaryrefslogtreecommitdiff
path: root/ucbhelper/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-12-23 18:05:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-12-27 14:18:27 +0100
commit42050ccb71663a776d6bc79d3f24ea0932f1245e (patch)
treeb555d71a38a924c48aa8f6c307643d77a284f3ac /ucbhelper/source
parent42ac3410c0642c5c00023c3d6fb2df093af5fe94 (diff)
osl::Mutex->std::mutex in PropertySetInfo
Change-Id: I6db00939e9896fc2798d2eea09a7675fb9504f37 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127542 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucbhelper/source')
-rw-r--r--ucbhelper/source/provider/contentinfo.cxx86
-rw-r--r--ucbhelper/source/provider/contentinfo.hxx14
2 files changed, 48 insertions, 52 deletions
diff --git a/ucbhelper/source/provider/contentinfo.cxx b/ucbhelper/source/provider/contentinfo.cxx
index 28be385ea215..76dfb68dbf6b 100644
--- a/ucbhelper/source/provider/contentinfo.cxx
+++ b/ucbhelper/source/provider/contentinfo.cxx
@@ -62,54 +62,52 @@ PropertySetInfo::~PropertySetInfo()
// virtual
uno::Sequence< beans::Property > SAL_CALL PropertySetInfo::getProperties()
{
- if ( !m_xProps )
- {
- osl::MutexGuard aGuard( m_aMutex );
- if ( !m_xProps )
- {
-
- // Get info for core ( native) properties.
-
+ std::unique_lock aGuard( m_aMutex );
+ return getPropertiesImpl();
+}
- try
- {
- m_xProps = m_pContent->getProperties( m_xEnv );
- }
- catch ( uno::RuntimeException const & )
- {
- throw;
- }
- catch ( uno::Exception const & )
- {
- m_xProps.emplace();
- }
+const uno::Sequence< beans::Property > & PropertySetInfo::getPropertiesImpl()
+{
+ if ( m_xProps )
+ return *m_xProps;
+ // Get info for core ( native) properties.
- // Get info for additional properties.
+ try
+ {
+ m_xProps = m_pContent->getProperties( m_xEnv );
+ }
+ catch ( uno::RuntimeException const & )
+ {
+ throw;
+ }
+ catch ( uno::Exception const & )
+ {
+ m_xProps.emplace();
+ }
+ // Get info for additional properties.
- uno::Reference< css::ucb::XPersistentPropertySet >
- xSet ( m_pContent->getAdditionalPropertySet( false ) );
+ uno::Reference< css::ucb::XPersistentPropertySet >
+ xSet ( m_pContent->getAdditionalPropertySet( false ) );
- if ( xSet.is() )
+ if ( xSet.is() )
+ {
+ // Get property set info.
+ uno::Reference< beans::XPropertySetInfo > xInfo(
+ xSet->getPropertySetInfo() );
+ if ( xInfo.is() )
+ {
+ const uno::Sequence< beans::Property >& rAddProps
+ = xInfo->getProperties();
+ sal_Int32 nAddProps = rAddProps.getLength();
+ if ( nAddProps > 0 )
{
- // Get property set info.
- uno::Reference< beans::XPropertySetInfo > xInfo(
- xSet->getPropertySetInfo() );
- if ( xInfo.is() )
- {
- const uno::Sequence< beans::Property >& rAddProps
- = xInfo->getProperties();
- sal_Int32 nAddProps = rAddProps.getLength();
- if ( nAddProps > 0 )
- {
- sal_Int32 nPos = m_xProps->getLength();
- m_xProps->realloc( nPos + nAddProps );
-
- std::copy(rAddProps.begin(), rAddProps.end(),
- std::next(m_xProps->getArray(), nPos));
- }
- }
+ sal_Int32 nPos = m_xProps->getLength();
+ m_xProps->realloc( nPos + nAddProps );
+
+ std::copy(rAddProps.begin(), rAddProps.end(),
+ std::next(m_xProps->getArray(), nPos));
}
}
}
@@ -143,7 +141,7 @@ sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName(
void PropertySetInfo::reset()
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
m_xProps.reset();
}
@@ -151,9 +149,9 @@ void PropertySetInfo::reset()
bool PropertySetInfo::queryProperty(
std::u16string_view rName, beans::Property& rProp )
{
- osl::MutexGuard aGuard( m_aMutex );
+ std::unique_lock aGuard( m_aMutex );
- getProperties();
+ getPropertiesImpl();
const beans::Property* pProps = m_xProps->getConstArray();
sal_Int32 nCount = m_xProps->getLength();
diff --git a/ucbhelper/source/provider/contentinfo.hxx b/ucbhelper/source/provider/contentinfo.hxx
index 6554c7fcfe66..15a122d3c83d 100644
--- a/ucbhelper/source/provider/contentinfo.hxx
+++ b/ucbhelper/source/provider/contentinfo.hxx
@@ -27,6 +27,7 @@
#include <cppuhelper/implbase.hxx>
#include <osl/mutex.hxx>
+#include <mutex>
namespace com::sun::star::ucb { class XCommandEnvironment; }
@@ -50,12 +51,13 @@ class PropertySetInfo :
m_xEnv;
std::optional<css::uno::Sequence< css::beans::Property >>
m_xProps;
- osl::Mutex m_aMutex;
+ std::mutex m_aMutex;
ContentImplHelper* m_pContent;
private:
bool queryProperty( std::u16string_view rName,
css::beans::Property& rProp );
+ const css::uno::Sequence< css::beans::Property > & getPropertiesImpl();
public:
PropertySetInfo( const css::uno::Reference< css::ucb::XCommandEnvironment >& rxEnv,
@@ -63,13 +65,9 @@ public:
virtual ~PropertySetInfo() override;
// XPropertySetInfo
- virtual css::uno::Sequence<
- css::beans::Property > SAL_CALL
- getProperties() override;
- virtual css::beans::Property SAL_CALL
- getPropertyByName( const OUString& aName ) override;
- virtual sal_Bool SAL_CALL
- hasPropertyByName( const OUString& Name ) override;
+ virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() override;
+ virtual css::beans::Property SAL_CALL getPropertyByName( const OUString& aName ) override;
+ virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override;
// Non-Interface methods.
void reset();