ucbhelper/source/provider/contentinfo.cxx |   51 ++++++++++++++----------------
 ucbhelper/source/provider/contentinfo.hxx |   20 ++++-------
 2 files changed, 32 insertions(+), 39 deletions(-)

New commits:
commit 58a750598cb064f7d9a4569e80ce91f22a87512d
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Thu Dec 23 18:09:02 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Dec 27 15:21:05 2021 +0100

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

diff --git a/ucbhelper/source/provider/contentinfo.cxx 
b/ucbhelper/source/provider/contentinfo.cxx
index 76dfb68dbf6b..5ea61e825e8b 100644
--- a/ucbhelper/source/provider/contentinfo.cxx
+++ b/ucbhelper/source/provider/contentinfo.cxx
@@ -191,31 +191,30 @@ CommandProcessorInfo::~CommandProcessorInfo()
 
 
 // virtual
-uno::Sequence< css::ucb::CommandInfo > SAL_CALL
-CommandProcessorInfo::getCommands()
+uno::Sequence< css::ucb::CommandInfo > SAL_CALL 
CommandProcessorInfo::getCommands()
 {
-    if ( !m_xCommands )
-    {
-        osl::MutexGuard aGuard( m_aMutex );
-        if ( !m_xCommands )
-        {
+    std::unique_lock aGuard( m_aMutex );
+    return getCommandsImpl();
+}
 
-            // Get info for commands.
+const uno::Sequence< css::ucb::CommandInfo > & 
CommandProcessorInfo::getCommandsImpl()
+{
+    if ( m_xCommands )
+        return *m_xCommands;
 
+    // Get info for commands.
 
-            try
-            {
-                m_xCommands = m_pContent->getCommands( m_xEnv );
-            }
-            catch ( uno::RuntimeException const & )
-            {
-                throw;
-            }
-            catch ( uno::Exception const & )
-            {
-                m_xCommands.emplace();
-            }
-        }
+    try
+    {
+        m_xCommands = m_pContent->getCommands( m_xEnv );
+    }
+    catch ( uno::RuntimeException const & )
+    {
+        throw;
+    }
+    catch ( uno::Exception const & )
+    {
+        m_xCommands.emplace();
     }
     return *m_xCommands;
 }
@@ -268,7 +267,7 @@ sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByHandle( 
sal_Int32 Handle )
 
 void CommandProcessorInfo::reset()
 {
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
     m_xCommands.reset();
 }
 
@@ -277,9 +276,9 @@ bool CommandProcessorInfo::queryCommand(
     std::u16string_view rName,
     css::ucb::CommandInfo& rCommand )
 {
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
-    getCommands();
+    getCommandsImpl();
 
     const css::ucb::CommandInfo* pCommands
         = m_xCommands->getConstArray();
@@ -302,9 +301,9 @@ bool CommandProcessorInfo::queryCommand(
     sal_Int32 nHandle,
     css::ucb::CommandInfo& rCommand )
 {
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
-    getCommands();
+    getCommandsImpl();
 
     const css::ucb::CommandInfo* pCommands = m_xCommands->getConstArray();
     sal_Int32 nCount = m_xCommands->getLength();
diff --git a/ucbhelper/source/provider/contentinfo.hxx 
b/ucbhelper/source/provider/contentinfo.hxx
index 15a122d3c83d..eaff22c4ea05 100644
--- a/ucbhelper/source/provider/contentinfo.hxx
+++ b/ucbhelper/source/provider/contentinfo.hxx
@@ -26,7 +26,6 @@
 #include <com/sun/star/beans/XPropertySetInfo.hpp>
 #include <cppuhelper/implbase.hxx>
 
-#include <osl/mutex.hxx>
 #include <mutex>
 
 namespace com::sun::star::ucb { class XCommandEnvironment; }
@@ -88,7 +87,7 @@ class CommandProcessorInfo :
                                 m_xEnv;
     std::optional<css::uno::Sequence< css::ucb::CommandInfo >>
                                 m_xCommands;
-    osl::Mutex                  m_aMutex;
+    std::mutex                  m_aMutex;
     ContentImplHelper*          m_pContent;
 
 private:
@@ -96,6 +95,7 @@ private:
                            css::ucb::CommandInfo& rCommand );
     bool queryCommand( sal_Int32 nHandle,
                            css::ucb::CommandInfo& rCommand );
+    const css::uno::Sequence< css::ucb::CommandInfo > & getCommandsImpl();
 
 public:
     CommandProcessorInfo( const css::uno::Reference< 
css::ucb::XCommandEnvironment >& rxEnv,
@@ -103,17 +103,11 @@ public:
     virtual ~CommandProcessorInfo() override;
 
     // XCommandInfo
-    virtual css::uno::Sequence<
-                css::ucb::CommandInfo > SAL_CALL
-    getCommands() override;
-    virtual css::ucb::CommandInfo SAL_CALL
-    getCommandInfoByName( const OUString& Name ) override;
-    virtual css::ucb::CommandInfo SAL_CALL
-    getCommandInfoByHandle( sal_Int32 Handle ) override;
-    virtual sal_Bool SAL_CALL
-    hasCommandByName( const OUString& Name ) override;
-    virtual sal_Bool SAL_CALL
-    hasCommandByHandle( sal_Int32 Handle ) override;
+    virtual css::uno::Sequence< css::ucb::CommandInfo > SAL_CALL getCommands() 
override;
+    virtual css::ucb::CommandInfo SAL_CALL getCommandInfoByName( const 
OUString& Name ) override;
+    virtual css::ucb::CommandInfo SAL_CALL getCommandInfoByHandle( sal_Int32 
Handle ) override;
+    virtual sal_Bool SAL_CALL hasCommandByName( const OUString& Name ) 
override;
+    virtual sal_Bool SAL_CALL hasCommandByHandle( sal_Int32 Handle ) override;
 
     // Non-Interface methods.
     void reset();

Reply via email to