ucb/source/core/ucbstore.cxx |  392 ++++++++++++++++++++++---------------------
 ucb/source/core/ucbstore.hxx |   28 +--
 2 files changed, 220 insertions(+), 200 deletions(-)

New commits:
commit bcd2650598dbe7c2c6bcaa693f5ba3880e08c4ad
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Feb 13 09:37:27 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Feb 13 16:07:36 2023 +0000

    osl::Mutex->std::mutex in PropertySetRegistry
    
    Change-Id: I08a059998cb13f12ad6183ee54754525386dfcd4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146853
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index 08fac6d0f7fe..b1b42730f249 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -240,122 +240,121 @@ css::uno::Sequence< OUString > SAL_CALL 
PropertySetRegistry::getSupportedService
 Reference< XPersistentPropertySet > SAL_CALL
 PropertySetRegistry::openPropertySet( const OUString& key, sal_Bool create )
 {
-    if ( !key.isEmpty() )
-    {
-        osl::Guard< osl::Mutex > aGuard( m_aMutex );
+    if ( key.isEmpty() )
+        return Reference< XPersistentPropertySet >();
 
-        PropertySetMap_Impl& rSets = m_aPropSets;
+    std::unique_lock aGuard( m_aMutex );
 
-        PropertySetMap_Impl::const_iterator it = rSets.find( key );
-        if ( it != rSets.end() )
-        {
-            // Already instantiated.
-            return Reference< XPersistentPropertySet >( (*it).second );
-        }
-        else
-        {
-            // Create new instance.
-            Reference< XNameAccess > xRootNameAccess(
-                                    getRootConfigReadAccess(), UNO_QUERY );
-            if ( xRootNameAccess.is() )
-            {
-                // Propertyset in registry?
-                if ( xRootNameAccess->hasByName( key ) )
-                {
-                    // Yep!
-                    return Reference< XPersistentPropertySet >(
-                                            new PersistentPropertySet(
-                                                    *this, key ) );
-                }
-                else if ( create )
-                {
-                    // No. Create entry for propertyset.
+    PropertySetMap_Impl& rSets = m_aPropSets;
 
-                    Reference< XSingleServiceFactory > xFac(
-                            getConfigWriteAccess( OUString() ), UNO_QUERY );
-                    Reference< XChangesBatch >  xBatch( xFac, UNO_QUERY );
-                    Reference< XNameContainer > xContainer( xFac, UNO_QUERY );
+    PropertySetMap_Impl::const_iterator it = rSets.find( key );
+    if ( it != rSets.end() )
+        // Already instantiated.
+        return Reference< XPersistentPropertySet >( (*it).second );
 
-                    OSL_ENSURE( xFac.is(),
-                                "PropertySetRegistry::openPropertySet - "
-                                "No factory!" );
+    // Create new instance.
+    Reference< XNameAccess > xRootNameAccess(
+                            getRootConfigReadAccessImpl(aGuard), UNO_QUERY );
+    if ( !xRootNameAccess.is() )
+    {
+        SAL_WARN( "ucb", "no root access" );
+        return Reference< XPersistentPropertySet >();
+    }
 
-                    OSL_ENSURE( xBatch.is(),
-                                "PropertySetRegistry::openPropertySet - "
-                                "No batch!" );
+    // Propertyset in registry?
+    if ( xRootNameAccess->hasByName( key ) )
+    {
+        // Yep!
+        return Reference< XPersistentPropertySet >(
+                                new PersistentPropertySet(
+                                        aGuard, *this, key ) );
+    }
+    else if ( create )
+    {
+        // No. Create entry for propertyset.
 
-                    OSL_ENSURE( xContainer.is(),
-                                "PropertySetRegistry::openPropertySet - "
-                                "No container!" );
+        Reference< XSingleServiceFactory > xFac(
+                getConfigWriteAccessImpl( aGuard, OUString() ), UNO_QUERY );
+        Reference< XChangesBatch >  xBatch( xFac, UNO_QUERY );
+        Reference< XNameContainer > xContainer( xFac, UNO_QUERY );
 
-                    if ( xFac.is() && xBatch.is() && xContainer.is() )
-                    {
-                        try
-                        {
-                            // Create new "Properties" config item.
-                            Reference< XNameReplace > xNameReplace(
-                                        xFac->createInstance(), UNO_QUERY );
+        OSL_ENSURE( xFac.is(),
+                    "PropertySetRegistry::openPropertySet - "
+                    "No factory!" );
 
-                            if ( xNameReplace.is() )
-                            {
-                                // Fill new item...
-
-                                // Insert new item.
-                                xContainer->insertByName(
-                                        key, Any( xNameReplace ) );
-                                // Commit changes.
-                                xBatch->commitChanges();
+        OSL_ENSURE( xBatch.is(),
+                    "PropertySetRegistry::openPropertySet - "
+                    "No batch!" );
 
-                                return Reference< XPersistentPropertySet >(
-                                            new PersistentPropertySet(
-                                                    *this, key ) );
-                            }
-                        }
-                        catch (const IllegalArgumentException&)
-                        {
-                            // insertByName
+        OSL_ENSURE( xContainer.is(),
+                    "PropertySetRegistry::openPropertySet - "
+                    "No container!" );
 
-                            OSL_FAIL( "PropertySetRegistry::openPropertySet - "
-                                        "caught IllegalArgumentException!" );
-                        }
-                        catch (const ElementExistException&)
-                        {
-                            // insertByName
+        if ( xFac.is() && xBatch.is() && xContainer.is() )
+        {
+            try
+            {
+                // Create new "Properties" config item.
+                Reference< XNameReplace > xNameReplace(
+                            xFac->createInstance(), UNO_QUERY );
 
-                            OSL_FAIL( "PropertySetRegistry::openPropertySet - "
-                                        "caught ElementExistException!" );
-                        }
-                        catch (const WrappedTargetException&)
-                        {
-                            // insertByName, commitChanges
+                if ( xNameReplace.is() )
+                {
+                    // Fill new item...
 
-                            OSL_FAIL( "PropertySetRegistry::openPropertySet - "
-                                        "caught WrappedTargetException!" );
-                        }
-                        catch (const RuntimeException&)
-                        {
-                            OSL_FAIL( "PropertySetRegistry::openPropertySet - "
-                                        "caught RuntimeException!" );
-                        }
-                        catch (const Exception&)
-                        {
-                            // createInstance
+                    // Insert new item.
+                    xContainer->insertByName(
+                            key, Any( xNameReplace ) );
+                    // Commit changes.
+                    xBatch->commitChanges();
 
-                            OSL_FAIL( "PropertySetRegistry::openPropertySet - "
-                                        "caught Exception!" );
-                        }
-                    }
-                }
-                else
-                {
-                    // No entry. Fail, but no error.
-                    return Reference< XPersistentPropertySet >();
+                    return Reference< XPersistentPropertySet >(
+                                new PersistentPropertySet(
+                                        aGuard, *this, key ) );
                 }
             }
+            catch (const IllegalArgumentException&)
+            {
+                // insertByName
+
+                OSL_FAIL( "PropertySetRegistry::openPropertySet - "
+                            "caught IllegalArgumentException!" );
+            }
+            catch (const ElementExistException&)
+            {
+                // insertByName
+
+                OSL_FAIL( "PropertySetRegistry::openPropertySet - "
+                            "caught ElementExistException!" );
+            }
+            catch (const WrappedTargetException&)
+            {
+                // insertByName, commitChanges
+
+                OSL_FAIL( "PropertySetRegistry::openPropertySet - "
+                            "caught WrappedTargetException!" );
+            }
+            catch (const RuntimeException&)
+            {
+                OSL_FAIL( "PropertySetRegistry::openPropertySet - "
+                            "caught RuntimeException!" );
+            }
+            catch (const Exception&)
+            {
+                // createInstance
 
-            SAL_WARN( "ucb", "no root access" );
+                OSL_FAIL( "PropertySetRegistry::openPropertySet - "
+                            "caught Exception!" );
+            }
         }
     }
+    else
+    {
+        // No entry. Fail, but no error.
+        return Reference< XPersistentPropertySet >();
+    }
+
+    SAL_WARN( "ucb", "no root access" );
 
     return Reference< XPersistentPropertySet >();
 }
@@ -367,17 +366,17 @@ void SAL_CALL PropertySetRegistry::removePropertySet( 
const OUString& key )
     if ( key.isEmpty() )
         return;
 
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
     Reference< XNameAccess > xRootNameAccess(
-                                    getRootConfigReadAccess(), UNO_QUERY );
+                                    getRootConfigReadAccessImpl(aGuard), 
UNO_QUERY );
     if ( xRootNameAccess.is() )
     {
         // Propertyset in registry?
         if ( !xRootNameAccess->hasByName( key ) )
             return;
         Reference< XChangesBatch > xBatch(
-                            getConfigWriteAccess( OUString() ), UNO_QUERY );
+                            getConfigWriteAccessImpl( aGuard, OUString() ), 
UNO_QUERY );
         Reference< XNameContainer > xContainer( xBatch, UNO_QUERY );
 
         if ( xBatch.is() && xContainer.is() )
@@ -430,8 +429,6 @@ css::uno::Type SAL_CALL 
PropertySetRegistry::getElementType()
 // virtual
 sal_Bool SAL_CALL PropertySetRegistry::hasElements()
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
     Reference< XElementAccess > xElemAccess(
                                     getRootConfigReadAccess(), UNO_QUERY );
     if ( xElemAccess.is() )
@@ -447,8 +444,6 @@ sal_Bool SAL_CALL PropertySetRegistry::hasElements()
 // virtual
 Any SAL_CALL PropertySetRegistry::getByName( const OUString& aName )
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
     Reference< XNameAccess > xNameAccess(
                                     getRootConfigReadAccess(), UNO_QUERY );
     if ( xNameAccess.is() )
@@ -475,8 +470,6 @@ Any SAL_CALL PropertySetRegistry::getByName( const 
OUString& aName )
 // virtual
 Sequence< OUString > SAL_CALL PropertySetRegistry::getElementNames()
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
     Reference< XNameAccess > xNameAccess(
                                     getRootConfigReadAccess(), UNO_QUERY );
     if ( xNameAccess.is() )
@@ -490,8 +483,6 @@ Sequence< OUString > SAL_CALL 
PropertySetRegistry::getElementNames()
 // virtual
 sal_Bool SAL_CALL PropertySetRegistry::hasByName( const OUString& aName )
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
     Reference< XNameAccess > xNameAccess(
                                     getRootConfigReadAccess(), UNO_QUERY );
     if ( xNameAccess.is() )
@@ -503,13 +494,14 @@ sal_Bool SAL_CALL PropertySetRegistry::hasByName( const 
OUString& aName )
 }
 
 
-void PropertySetRegistry::add( PersistentPropertySet* pSet )
+void PropertySetRegistry::add(
+        std::unique_lock<std::mutex>& /*rCreatorGuard*/,
+        PersistentPropertySet* pSet )
 {
     OUString key( pSet->getKey() );
 
     if ( !key.isEmpty() )
     {
-        osl::Guard< osl::Mutex > aGuard( m_aMutex );
         m_aPropSets[ key ] = pSet;
     }
 }
@@ -522,7 +514,7 @@ void PropertySetRegistry::remove( PersistentPropertySet* 
pSet )
     if ( key.isEmpty() )
         return;
 
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
     PropertySetMap_Impl& rSets = m_aPropSets;
 
@@ -836,34 +828,30 @@ void PropertySetRegistry::renamePropertySet( const 
OUString& rOldKey,
 }
 
 
-Reference< XMultiServiceFactory > PropertySetRegistry::getConfigProvider()
+Reference< XMultiServiceFactory > 
PropertySetRegistry::getConfigProvider(std::unique_lock<std::mutex>& /*rGuard*/)
 {
     if ( !m_xConfigProvider.is() )
     {
-        osl::Guard< osl::Mutex > aGuard( m_aMutex );
-        if ( !m_xConfigProvider.is() )
+        const Sequence< Any >& rInitArgs = m_aInitArgs;
+
+        if ( rInitArgs.hasElements() )
         {
-            const Sequence< Any >& rInitArgs = m_aInitArgs;
+            // Extract config provider from service init args.
+            rInitArgs[ 0 ] >>= m_xConfigProvider;
 
-            if ( rInitArgs.hasElements() )
+            OSL_ENSURE( m_xConfigProvider.is(),
+                        "PropertySetRegistry::getConfigProvider - "
+                        "No config provider!" );
+        }
+        else
+        {
+            try
             {
-                // Extract config provider from service init args.
-                rInitArgs[ 0 ] >>= m_xConfigProvider;
-
-                OSL_ENSURE( m_xConfigProvider.is(),
-                            "PropertySetRegistry::getConfigProvider - "
-                            "No config provider!" );
+                m_xConfigProvider = theDefaultProvider::get( m_xContext );
             }
-            else
+            catch (const Exception&)
             {
-                try
-                {
-                    m_xConfigProvider = theDefaultProvider::get( m_xContext );
-                }
-                catch (const Exception&)
-                {
-                    TOOLS_WARN_EXCEPTION( "ucb", "");
-                }
+                TOOLS_WARN_EXCEPTION( "ucb", "");
             }
         }
     }
@@ -873,11 +861,15 @@ Reference< XMultiServiceFactory > 
PropertySetRegistry::getConfigProvider()
 
 
 Reference< XInterface > PropertySetRegistry::getRootConfigReadAccess()
+{
+    std::unique_lock aGuard( m_aMutex );
+    return getRootConfigReadAccessImpl(aGuard);
+}
+
+Reference< XInterface > 
PropertySetRegistry::getRootConfigReadAccessImpl(std::unique_lock<std::mutex>& 
rGuard)
 {
     try
     {
-        osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
         if ( !m_xRootReadAccess.is() )
         {
             if ( m_bTriedToGetRootReadAccess )
@@ -887,7 +879,7 @@ Reference< XInterface > 
PropertySetRegistry::getRootConfigReadAccess()
                 return Reference< XInterface >();
             }
 
-            getConfigProvider();
+            getConfigProvider(rGuard);
 
             if ( m_xConfigProvider.is() )
             {
@@ -929,11 +921,16 @@ Reference< XInterface > 
PropertySetRegistry::getRootConfigReadAccess()
 
 Reference< XInterface > PropertySetRegistry::getConfigWriteAccess(
                                                     const OUString& rPath )
+{
+    std::unique_lock aGuard( m_aMutex );
+    return getConfigWriteAccessImpl(aGuard, rPath);
+}
+
+Reference< XInterface > 
PropertySetRegistry::getConfigWriteAccessImpl(std::unique_lock<std::mutex>& 
rGuard,
+                                                    const OUString& rPath )
 {
     try
     {
-        osl::Guard< osl::Mutex > aGuard( m_aMutex );
-
         if ( !m_xRootWriteAccess.is() )
         {
             if ( m_bTriedToGetRootWriteAccess )
@@ -943,7 +940,7 @@ Reference< XInterface > 
PropertySetRegistry::getConfigWriteAccess(
                 return Reference< XInterface >();
             }
 
-            getConfigProvider();
+            getConfigProvider(rGuard);
 
             if ( m_xConfigProvider.is() )
             {
@@ -1014,12 +1011,13 @@ Reference< XInterface > 
PropertySetRegistry::getConfigWriteAccess(
 
 
 PersistentPropertySet::PersistentPropertySet(
+                        std::unique_lock<std::mutex>& rCreatorGuard,
                         PropertySetRegistry& rCreator,
                         OUString aKey )
 : m_pCreator( &rCreator ), m_aKey(std::move( aKey ))
 {
     // register at creator.
-    rCreator.add( this );
+    rCreator.add( rCreatorGuard, this );
 }
 
 
diff --git a/ucb/source/core/ucbstore.hxx b/ucb/source/core/ucbstore.hxx
index 2ed9d97484fa..dceb65733864 100644
--- a/ucb/source/core/ucbstore.hxx
+++ b/ucb/source/core/ucbstore.hxx
@@ -87,15 +87,15 @@ class PropertySetRegistry : public cppu::WeakImplHelper <
     css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvider;
     css::uno::Reference< css::uno::XInterface >           m_xRootReadAccess;
     css::uno::Reference< css::uno::XInterface >           m_xRootWriteAccess;
-    osl::Mutex                        m_aMutex;
+    std::mutex                        m_aMutex;
     bool                              m_bTriedToGetRootReadAccess;
     bool                              m_bTriedToGetRootWriteAccess;
 
 private:
     css::uno::Reference< css::lang::XMultiServiceFactory >
-    getConfigProvider();
+    getConfigProvider(std::unique_lock<std::mutex>& l);
 
-    void add   ( PersistentPropertySet* pSet );
+    void add   ( std::unique_lock<std::mutex>& rCreatorGuard, 
PersistentPropertySet* pSet );
     void remove( PersistentPropertySet* pSet );
 
     void renamePropertySet( const OUString& rOldKey,
@@ -138,6 +138,11 @@ public:
     getRootConfigReadAccess();
     css::uno::Reference< css::uno::XInterface >
     getConfigWriteAccess( const OUString& rPath );
+private:
+    css::uno::Reference< css::uno::XInterface >
+    getRootConfigReadAccessImpl(std::unique_lock<std::mutex>& l);
+    css::uno::Reference< css::uno::XInterface >
+    getConfigWriteAccessImpl( std::unique_lock<std::mutex>& l, const OUString& 
rPath );
 };
 
 
@@ -170,6 +175,7 @@ private:
 
 public:
     PersistentPropertySet(
+        std::unique_lock<std::mutex>& rCreatorGuard,
         PropertySetRegistry& rCreator,
         OUString aKey );
     virtual ~PersistentPropertySet() override;
commit 756185b5795c95180d32d02abfbd65951779b40e
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Feb 13 09:06:02 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Feb 13 16:07:27 2023 +0000

    osl::Mutex->std::mutex in PersistentPropertySet
    
    Change-Id: If88ac207083a928e2315e2ec1c7ac40951fb2a6d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146851
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/ucb/source/core/ucbstore.cxx b/ucb/source/core/ucbstore.cxx
index 5757f8369f40..08fac6d0f7fe 100644
--- a/ucb/source/core/ucbstore.cxx
+++ b/ucb/source/core/ucbstore.cxx
@@ -1054,27 +1054,28 @@ css::uno::Sequence< OUString > SAL_CALL 
PersistentPropertySet::getSupportedServi
 // virtual
 void SAL_CALL PersistentPropertySet::dispose()
 {
+    std::unique_lock l(m_aMutex);
     if ( m_pDisposeEventListeners &&
-         m_pDisposeEventListeners->getLength() )
+         m_pDisposeEventListeners->getLength(l) )
     {
         EventObject aEvt;
         aEvt.Source = static_cast< XComponent * >( this  );
-        m_pDisposeEventListeners->disposeAndClear( aEvt );
+        m_pDisposeEventListeners->disposeAndClear( l, aEvt );
     }
 
     if ( m_pPropSetChangeListeners &&
-         m_pPropSetChangeListeners->getLength() )
+         m_pPropSetChangeListeners->getLength(l) )
     {
         EventObject aEvt;
         aEvt.Source = static_cast< XPropertySetInfoChangeNotifier * >( this  );
-        m_pPropSetChangeListeners->disposeAndClear( aEvt );
+        m_pPropSetChangeListeners->disposeAndClear( l, aEvt );
     }
 
     if ( m_pPropertyChangeListeners )
     {
         EventObject aEvt;
         aEvt.Source = static_cast< XPropertySet * >( this  );
-        m_pPropertyChangeListeners->disposeAndClear( aEvt );
+        m_pPropertyChangeListeners->disposeAndClear( l, aEvt );
     }
 }
 
@@ -1083,11 +1084,13 @@ void SAL_CALL PersistentPropertySet::dispose()
 void SAL_CALL PersistentPropertySet::addEventListener(
                             const Reference< XEventListener >& Listener )
 {
+    std::unique_lock l(m_aMutex);
+
     if ( !m_pDisposeEventListeners )
         m_pDisposeEventListeners.reset(
-                    new OInterfaceContainerHelper3<css::lang::XEventListener>( 
m_aMutex ) );
+                    new 
OInterfaceContainerHelper4<css::lang::XEventListener>() );
 
-    m_pDisposeEventListeners->addInterface( Listener );
+    m_pDisposeEventListeners->addInterface( l, Listener );
 }
 
 
@@ -1095,8 +1098,9 @@ void SAL_CALL PersistentPropertySet::addEventListener(
 void SAL_CALL PersistentPropertySet::removeEventListener(
                             const Reference< XEventListener >& Listener )
 {
+    std::unique_lock l(m_aMutex);
     if ( m_pDisposeEventListeners )
-        m_pDisposeEventListeners->removeInterface( Listener );
+        m_pDisposeEventListeners->removeInterface( l, Listener );
 
     // Note: Don't want to delete empty container here -> performance.
 }
@@ -1108,7 +1112,7 @@ void SAL_CALL PersistentPropertySet::removeEventListener(
 // virtual
 Reference< XPropertySetInfo > SAL_CALL 
PersistentPropertySet::getPropertySetInfo()
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
+    std::unique_lock l(m_aMutex);
 
     if ( !m_pInfo.is() )
     {
@@ -1122,13 +1126,13 @@ Reference< XPropertySetInfo > SAL_CALL 
PersistentPropertySet::getPropertySetInfo
 void SAL_CALL PersistentPropertySet::setPropertyValue( const OUString& 
aPropertyName,
                                                        const Any& aValue )
 {
-    osl::ClearableGuard< osl::Mutex > aCGuard( m_aMutex );
+    std::unique_lock aCGuard(m_aMutex);
 
     Reference< XHierarchicalNameAccess > xRootHierNameAccess(
                 m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
     if ( xRootHierNameAccess.is() )
     {
-        OUString aFullPropName( getFullKey() + "/" );
+        OUString aFullPropName( getFullKeyImpl(aCGuard) + "/" );
         aFullPropName += makeHierarchalNameSegment( aPropertyName );
 
         // Does property exist?
@@ -1153,7 +1157,6 @@ void SAL_CALL PersistentPropertySet::setPropertyValue( 
const OUString& aProperty
                     // Check value type.
                     if ( aOldValue.getValueType() != aValue.getValueType() )
                     {
-                        aCGuard.clear();
                         throw IllegalArgumentException();
                     }
 
@@ -1187,7 +1190,7 @@ void SAL_CALL PersistentPropertySet::setPropertyValue( 
const OUString& aProperty
                         aEvt.NewValue       = aValue;
 
                         // Callback follows!
-                        aCGuard.clear();
+                        aCGuard.unlock();
 
                         notifyPropertyChangeEvent( aEvt );
                     }
@@ -1217,13 +1220,13 @@ void SAL_CALL PersistentPropertySet::setPropertyValue( 
const OUString& aProperty
 Any SAL_CALL PersistentPropertySet::getPropertyValue(
                                             const OUString& PropertyName )
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
+    std::unique_lock aGuard(m_aMutex);
 
     Reference< XHierarchicalNameAccess > xNameAccess(
                 m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
     if ( xNameAccess.is() )
     {
-        OUString aFullPropName( getFullKey() + "/" );
+        OUString aFullPropName( getFullKeyImpl(aGuard) + "/" );
         aFullPropName += makeHierarchalNameSegment( PropertyName ) + "/Value";
         try
         {
@@ -1246,12 +1249,12 @@ void SAL_CALL 
PersistentPropertySet::addPropertyChangeListener(
 {
 //  load();
 
+    std::unique_lock aGuard(m_aMutex);
+
     if ( !m_pPropertyChangeListeners )
-        m_pPropertyChangeListeners.reset(
-                    new PropertyListeners_Impl( m_aMutex ) );
+        m_pPropertyChangeListeners.reset( new PropertyListeners_Impl() );
 
-    m_pPropertyChangeListeners->addInterface(
-                                                aPropertyName, xListener );
+    m_pPropertyChangeListeners->addInterface(aGuard, aPropertyName, xListener 
);
 }
 
 
@@ -1262,8 +1265,10 @@ void SAL_CALL 
PersistentPropertySet::removePropertyChangeListener(
 {
 //  load();
 
+    std::unique_lock aGuard(m_aMutex);
+
     if ( m_pPropertyChangeListeners )
-        m_pPropertyChangeListeners->removeInterface(
+        m_pPropertyChangeListeners->removeInterface(aGuard,
                                                 aPropertyName, aListener );
 
     // Note: Don't want to delete empty container here -> performance.
@@ -1343,7 +1348,7 @@ void SAL_CALL PersistentPropertySet::addProperty(
     if ( eTypeClass == TypeClass_INTERFACE )
         throw IllegalTypeException();
 
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
+    std::unique_lock aGuard(m_aMutex);
 
     // Property already in set?
 
@@ -1353,7 +1358,7 @@ void SAL_CALL PersistentPropertySet::addProperty(
                 m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
     if ( xRootHierNameAccess.is() )
     {
-        aFullValuesName = getFullKey();
+        aFullValuesName = getFullKeyImpl(aGuard);
         OUString aFullPropName = aFullValuesName + "/";
         aFullPropName += makeHierarchalNameSegment( Name );
 
@@ -1432,7 +1437,7 @@ void SAL_CALL PersistentPropertySet::addProperty(
 
                 // Notify propertyset info change listeners.
                 if ( m_pPropSetChangeListeners &&
-                     m_pPropSetChangeListeners->getLength() )
+                     m_pPropSetChangeListeners->getLength(aGuard) )
                 {
                     PropertySetInfoChangeEvent evt(
                                     static_cast< OWeakObject * >( this ),
@@ -1491,13 +1496,13 @@ void SAL_CALL PersistentPropertySet::addProperty(
 // virtual
 void SAL_CALL PersistentPropertySet::removeProperty( const OUString& Name )
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
+    std::unique_lock aGuard(m_aMutex);
 
     Reference< XHierarchicalNameAccess > xRootHierNameAccess(
                 m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
     if ( xRootHierNameAccess.is() )
     {
-        OUString aFullValuesName = getFullKey();
+        OUString aFullValuesName = getFullKeyImpl(aGuard);
         OUString aFullPropName   = aFullValuesName + "/";
         aFullPropName   += makeHierarchalNameSegment( Name );
 
@@ -1557,7 +1562,7 @@ void SAL_CALL PersistentPropertySet::removeProperty( 
const OUString& Name )
                 sal_Int32 nHandle = -1;
 
                 if ( m_pPropSetChangeListeners &&
-                       m_pPropSetChangeListeners->getLength() )
+                       m_pPropSetChangeListeners->getLength(aGuard) )
                 {
                     // Obtain property handle ( needed for propertysetinfo
                     // change event )...
@@ -1590,7 +1595,7 @@ void SAL_CALL PersistentPropertySet::removeProperty( 
const OUString& Name )
 
                 // Notify propertyset info change listeners.
                 if ( m_pPropSetChangeListeners &&
-                      m_pPropSetChangeListeners->getLength() )
+                      m_pPropSetChangeListeners->getLength(aGuard) )
                 {
                     PropertySetInfoChangeEvent evt(
                                     static_cast< OWeakObject * >( this ),
@@ -1633,11 +1638,13 @@ void SAL_CALL PersistentPropertySet::removeProperty( 
const OUString& Name )
 void SAL_CALL PersistentPropertySet::addPropertySetInfoChangeListener(
                 const Reference< XPropertySetInfoChangeListener >& Listener )
 {
+    std::unique_lock aGuard(m_aMutex);
+
     if ( !m_pPropSetChangeListeners )
         m_pPropSetChangeListeners.reset(
-                    new 
OInterfaceContainerHelper3<XPropertySetInfoChangeListener>( m_aMutex ) );
+                    new 
OInterfaceContainerHelper4<XPropertySetInfoChangeListener>() );
 
-    m_pPropSetChangeListeners->addInterface( Listener );
+    m_pPropSetChangeListeners->addInterface( aGuard, Listener );
 }
 
 
@@ -1645,8 +1652,9 @@ void SAL_CALL 
PersistentPropertySet::addPropertySetInfoChangeListener(
 void SAL_CALL PersistentPropertySet::removePropertySetInfoChangeListener(
                 const Reference< XPropertySetInfoChangeListener >& Listener )
 {
+    std::unique_lock aGuard(m_aMutex);
     if ( m_pPropSetChangeListeners )
-        m_pPropSetChangeListeners->removeInterface( Listener );
+        m_pPropSetChangeListeners->removeInterface( aGuard, Listener );
 }
 
 
@@ -1656,7 +1664,7 @@ void SAL_CALL 
PersistentPropertySet::removePropertySetInfoChangeListener(
 // virtual
 Sequence< PropertyValue > SAL_CALL PersistentPropertySet::getPropertyValues()
 {
-    osl::Guard< osl::Mutex > aGuard( m_aMutex );
+    std::unique_lock aGuard(m_aMutex);
 
     Reference< XHierarchicalNameAccess > xRootHierNameAccess(
                 m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
@@ -1665,7 +1673,7 @@ Sequence< PropertyValue > SAL_CALL 
PersistentPropertySet::getPropertyValues()
         try
         {
             Reference< XNameAccess > xNameAccess;
-            xRootHierNameAccess->getByHierarchicalName(getFullKey())
+            xRootHierNameAccess->getByHierarchicalName(getFullKeyImpl(aGuard))
                 >>= xNameAccess;
             if ( xNameAccess.is() )
             {
@@ -1789,7 +1797,7 @@ void SAL_CALL PersistentPropertySet::setPropertyValues(
     if ( !aProps.hasElements() )
         return;
 
-    osl::ClearableGuard< osl::Mutex > aCGuard( m_aMutex );
+    std::unique_lock aCGuard(m_aMutex);
 
     Reference< XHierarchicalNameAccess > xRootHierNameAccess(
                 m_pCreator->getRootConfigReadAccess(), UNO_QUERY );
@@ -1797,7 +1805,7 @@ void SAL_CALL PersistentPropertySet::setPropertyValues(
     {
         std::vector< PropertyChangeEvent > aEvents;
 
-        OUString aFullPropNamePrefix( getFullKey() + "/" );
+        OUString aFullPropNamePrefix( getFullKeyImpl(aCGuard) + "/" );
 
         // Iterate over given property value sequence.
         for ( const PropertyValue& rNewValue : aProps )
@@ -1875,11 +1883,11 @@ void SAL_CALL PersistentPropertySet::setPropertyValues(
             }
         }
 
-        // Callback follows!
-        aCGuard.clear();
-
         if ( m_pPropertyChangeListeners )
         {
+            // Callback follows!
+            aCGuard.unlock();
+
             // Notify property changes.
             for (auto const& event : aEvents)
             {
@@ -1900,20 +1908,22 @@ void SAL_CALL PersistentPropertySet::setPropertyValues(
 void PersistentPropertySet::notifyPropertyChangeEvent(
                                     const PropertyChangeEvent& rEvent ) const
 {
+    std::unique_lock aGuard(m_aMutex);
+
     // Get "normal" listeners for the property.
-    OInterfaceContainerHelper3<XPropertyChangeListener>* pContainer =
+    OInterfaceContainerHelper4<XPropertyChangeListener>* pContainer =
             m_pPropertyChangeListeners->getContainer( rEvent.PropertyName );
-    if ( pContainer && pContainer->getLength() )
+    if ( pContainer && pContainer->getLength(aGuard) )
     {
-        pContainer->notifyEach( &XPropertyChangeListener::propertyChange, 
rEvent );
+        pContainer->notifyEach( aGuard, 
&XPropertyChangeListener::propertyChange, rEvent );
     }
 
     // Get "normal" listeners for all properties.
-    OInterfaceContainerHelper3<XPropertyChangeListener>* pNoNameContainer =
+    OInterfaceContainerHelper4<XPropertyChangeListener>* pNoNameContainer =
             m_pPropertyChangeListeners->getContainer( OUString() );
-    if ( pNoNameContainer && pNoNameContainer->getLength() )
+    if ( pNoNameContainer && pNoNameContainer->getLength(aGuard) )
     {
-        pNoNameContainer->notifyEach( 
&XPropertyChangeListener::propertyChange, rEvent );
+        pNoNameContainer->notifyEach( aGuard, 
&XPropertyChangeListener::propertyChange, rEvent );
     }
 }
 
@@ -1921,24 +1931,28 @@ void PersistentPropertySet::notifyPropertyChangeEvent(
 void PersistentPropertySet::notifyPropertySetInfoChange(
                                 const PropertySetInfoChangeEvent& evt ) const
 {
+    std::unique_lock aGuard(m_aMutex);
+
     if ( !m_pPropSetChangeListeners )
         return;
 
     // Notify event listeners.
-    m_pPropSetChangeListeners->notifyEach( 
&XPropertySetInfoChangeListener::propertySetInfoChange, evt );
+    m_pPropSetChangeListeners->notifyEach( aGuard, 
&XPropertySetInfoChangeListener::propertySetInfoChange, evt );
 }
 
 
-const OUString& PersistentPropertySet::getFullKey()
+OUString PersistentPropertySet::getFullKey()
+{
+    std::unique_lock aGuard(m_aMutex);
+    return getFullKeyImpl(aGuard);
+}
+
+const OUString& 
PersistentPropertySet::getFullKeyImpl(std::unique_lock<std::mutex>& )
 {
     if ( m_aFullKey.isEmpty() )
     {
-        osl::Guard< osl::Mutex > aGuard( m_aMutex );
-        if ( m_aFullKey.isEmpty() )
-        {
-            m_aFullKey = makeHierarchalNameSegment( m_aKey );
-            m_aFullKey += "/Values";
-        }
+        m_aFullKey = makeHierarchalNameSegment( m_aKey );
+        m_aFullKey += "/Values";
     }
 
     return m_aFullKey;
diff --git a/ucb/source/core/ucbstore.hxx b/ucb/source/core/ucbstore.hxx
index 322d64f05afa..2ed9d97484fa 100644
--- a/ucb/source/core/ucbstore.hxx
+++ b/ucb/source/core/ucbstore.hxx
@@ -32,8 +32,8 @@
 #include <com/sun/star/beans/XPropertyAccess.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
-#include <comphelper/interfacecontainer3.hxx>
-#include <comphelper/multiinterfacecontainer3.hxx>
+#include <comphelper/interfacecontainer4.hxx>
+#include <comphelper/multiinterfacecontainer4.hxx>
 #include <comphelper/compbase.hxx>
 #include <rtl/ref.hxx>
 #include <unordered_map>
@@ -142,7 +142,7 @@ public:
 
 
 class PropertySetInfo_Impl;
-typedef 
comphelper::OMultiTypeInterfaceContainerHelperVar3<css::beans::XPropertyChangeListener,
 OUString> PropertyListeners_Impl;
+typedef comphelper::OMultiTypeInterfaceContainerHelperVar4<OUString, 
css::beans::XPropertyChangeListener> PropertyListeners_Impl;
 
 class PersistentPropertySet : public cppu::WeakImplHelper <
     css::lang::XServiceInfo,
@@ -157,9 +157,9 @@ class PersistentPropertySet : public cppu::WeakImplHelper <
     rtl::Reference<PropertySetInfo_Impl> m_pInfo;
     OUString                    m_aKey;
     OUString                    m_aFullKey;
-    osl::Mutex                  m_aMutex;
-    
std::unique_ptr<comphelper::OInterfaceContainerHelper3<css::lang::XEventListener>>
  m_pDisposeEventListeners;
-    
std::unique_ptr<comphelper::OInterfaceContainerHelper3<css::beans::XPropertySetInfoChangeListener>>
  m_pPropSetChangeListeners;
+    mutable std::mutex          m_aMutex;
+    
std::unique_ptr<comphelper::OInterfaceContainerHelper4<css::lang::XEventListener>>
  m_pDisposeEventListeners;
+    
std::unique_ptr<comphelper::OInterfaceContainerHelper4<css::beans::XPropertySetInfoChangeListener>>
  m_pPropSetChangeListeners;
     std::unique_ptr<PropertyListeners_Impl>      m_pPropertyChangeListeners;
 
 private:
@@ -242,7 +242,9 @@ public:
 
     // Non-interface methods.
     PropertySetRegistry& getPropertySetRegistry();
-    const OUString& getFullKey();
+    OUString getFullKey();
+private:
+    const OUString& getFullKeyImpl(std::unique_lock<std::mutex>&);
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to