connectivity/source/parse/sqlnode.cxx         |   10 ++++--
 include/connectivity/sqlparse.hxx             |    9 ++----
 xmlhelp/source/cxxhelp/provider/databases.cxx |   39 ++++++++++++++------------
 xmlhelp/source/cxxhelp/provider/databases.hxx |    6 ++--
 4 files changed, 35 insertions(+), 29 deletions(-)

New commits:
commit a60fcb15046a60fa35fc4ea07d1411bf3563fe2e
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Feb 21 15:38:12 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Feb 22 09:16:10 2023 +0000

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

diff --git a/connectivity/source/parse/sqlnode.cxx 
b/connectivity/source/parse/sqlnode.cxx
index d98e8cc80064..fecb00cdc9b2 100644
--- a/connectivity/source/parse/sqlnode.cxx
+++ b/connectivity/source/parse/sqlnode.cxx
@@ -2731,13 +2731,13 @@ OSQLParseNodesContainer::~OSQLParseNodesContainer()
 
 void OSQLParseNodesContainer::push_back(OSQLParseNode* _pNode)
 {
-    ::osl::MutexGuard aGuard(m_aMutex);
+    std::unique_lock aGuard(m_aMutex);
     m_aNodes.push_back(_pNode);
 }
 
 void OSQLParseNodesContainer::erase(OSQLParseNode* _pNode)
 {
-    ::osl::MutexGuard aGuard(m_aMutex);
+    std::unique_lock aGuard(m_aMutex);
     if ( !m_aNodes.empty() )
     {
         std::vector< OSQLParseNode* >::iterator aFind = 
std::find(m_aNodes.begin(), m_aNodes.end(),_pNode);
@@ -2748,13 +2748,13 @@ void OSQLParseNodesContainer::erase(OSQLParseNode* 
_pNode)
 
 void OSQLParseNodesContainer::clear()
 {
-    ::osl::MutexGuard aGuard(m_aMutex);
+    std::unique_lock aGuard(m_aMutex);
     m_aNodes.clear();
 }
 
 void OSQLParseNodesContainer::clearAndDelete()
 {
-    ::osl::MutexGuard aGuard(m_aMutex);
+    std::unique_lock aGuard(m_aMutex);
     // clear the garbage collector
     while ( !m_aNodes.empty() )
     {
@@ -2763,7 +2763,9 @@ void OSQLParseNodesContainer::clearAndDelete()
         {
             pNode = pNode->getParent();
         }
+        aGuard.unlock(); // can call back into this object during destruction
         delete pNode;
+        aGuard.lock();
     }
 }
 }   // namespace connectivity
diff --git a/include/connectivity/sqlparse.hxx 
b/include/connectivity/sqlparse.hxx
index 0a8523e436a8..d3eedd484137 100644
--- a/include/connectivity/sqlparse.hxx
+++ b/include/connectivity/sqlparse.hxx
@@ -19,11 +19,7 @@
 #ifndef INCLUDED_CONNECTIVITY_SQLPARSE_HXX
 #define INCLUDED_CONNECTIVITY_SQLPARSE_HXX
 
-#include <memory>
-#include <string_view>
-
 #include <com/sun/star/uno/Reference.h>
-#include <osl/mutex.hxx>
 #include <connectivity/sqlnode.hxx>
 #include <connectivity/IParseContext.hxx>
 #include <connectivity/dbtoolsdllapi.hxx>
@@ -31,6 +27,9 @@
 #include <comphelper/singletonref.hxx>
 
 #include <map>
+#include <memory>
+#include <mutex>
+#include <string_view>
 
 namespace com::sun::star::i18n { class XCharacterClassification; }
 namespace com::sun::star::i18n { class XLocaleData4; }
@@ -82,7 +81,7 @@ namespace connectivity
 
     class OSQLParseNodesContainer
     {
-        ::osl::Mutex m_aMutex;
+        std::mutex m_aMutex;
         ::std::vector< OSQLParseNode* > m_aNodes;
     public:
         OSQLParseNodesContainer();
commit 2c37a0ca31095165d05740a2ff4969f625b4a75b
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Feb 21 15:35:20 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Feb 22 09:16:01 2023 +0000

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

diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx 
b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 48659524de0e..256230149ec2 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -81,7 +81,7 @@ using namespace com::sun::star::beans;
 
 OUString Databases::expandURL( const OUString& aURL )
 {
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
     OUString aRetURL = expandURL( aURL, m_xContext );
     return aRetURL;
 }
@@ -267,7 +267,7 @@ void Databases::replaceName( OUString& oustring ) const
 
 OUString Databases::getInstallPathAsURL()
 {
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
     return m_aInstallDirectory;
 }
@@ -313,9 +313,9 @@ const std::vector< OUString >& Databases::getModuleList( 
const OUString& Languag
 StaticModuleInformation* Databases::getStaticInformationForModule( 
std::u16string_view Module,
                                                                    const 
OUString& Language )
 {
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
-    OUString key = processLang(Language) + "/" + Module;
+    OUString key = processLang(aGuard, Language) + "/" + Module;
 
     std::pair< ModInfoTable::iterator,bool > aPair =
         m_aModInfo.emplace(key,nullptr);
@@ -324,7 +324,7 @@ StaticModuleInformation* 
Databases::getStaticInformationForModule( std::u16strin
 
     if( aPair.second && ! it->second )
     {
-        osl::File cfgFile( getInstallPathAsURL() + key + ".cfg" );
+        osl::File cfgFile( m_aInstallDirectory + key + ".cfg" );
 
         if( osl::FileBase::E_None != cfgFile.open( osl_File_OpenFlag_Read ) )
             it->second = nullptr;
@@ -389,8 +389,12 @@ StaticModuleInformation* 
Databases::getStaticInformationForModule( std::u16strin
 
 OUString Databases::processLang( const OUString& Language )
 {
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
+    return processLang(aGuard, Language);
+}
 
+OUString Databases::processLang( std::unique_lock<std::mutex>& /*rGuard*/, 
const OUString& Language )
+{
     OUString ret;
     LangSetTable::iterator it = m_aLangSet.find( Language );
 
@@ -407,7 +411,7 @@ OUString Databases::processLang( const OUString& Language )
         std::vector<OUString> aFallbacks( LanguageTag( 
aBcp47).getFallbackStrings(true));
         for (auto const & rFB : aFallbacks)
         {
-            if (osl::FileBase::E_None == osl::DirectoryItem::get( 
getInstallPathAsURL() + rFB, aDirItem))
+            if (osl::FileBase::E_None == osl::DirectoryItem::get( 
m_aInstallDirectory + rFB, aDirItem))
             {
                 ret = rFB;
                 m_aLangSet[ Language ] = ret;
@@ -428,13 +432,13 @@ helpdatafileproxy::Hdf* Databases::getHelpDataFile( 
std::u16string_view Database
     if( Database.empty() || Language.isEmpty() )
         return nullptr;
 
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
     OUString aFileExt( helpText ? OUString(".ht") : OUString(".db") );
     OUString dbFileName = OUString::Concat("/") + Database + aFileExt;
     OUString key;
     if( pExtensionPath == nullptr )
-        key = processLang( Language ) + dbFileName;
+        key = processLang( aGuard, Language ) + dbFileName;
     else
         key = *pExtensionPath + Language + dbFileName;      // make unique, 
don't change language
 
@@ -451,7 +455,7 @@ helpdatafileproxy::Hdf* Databases::getHelpDataFile( 
std::u16string_view Database
         if( pExtensionPath )
             fileURL = expandURL(*pExtensionPath) + Language + dbFileName;
         else
-            fileURL = getInstallPathAsURL() + key;
+            fileURL = m_aInstallDirectory + key;
 
         OUString fileNameHDFHelp( fileURL );
         //Extensions always use the new format
@@ -475,7 +479,7 @@ Databases::getCollator( const OUString& Language )
 {
     OUString key = Language;
 
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
     CollatorTable::iterator it =
         m_aCollatorTable.emplace( key, Reference< XCollator >() ).first;
@@ -701,9 +705,9 @@ bool Databases::checkModuleMatchForExtension
 KeywordInfo* Databases::getKeyword( const OUString& Database,
                                     const OUString& Language )
 {
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
-    OUString key = processLang(Language) + "/" + Database;
+    OUString key = processLang(aGuard, Language) + "/" + Database;
 
     std::pair< KeywordInfoTable::iterator,bool > aPair =
         m_aKeywordInfo.emplace( key,nullptr );
@@ -784,9 +788,10 @@ Reference< XHierarchicalNameAccess > Databases::jarFile( 
std::u16string_view jar
     {
         return Reference< XHierarchicalNameAccess >( nullptr );
     }
-    OUString key = processLang(Language) + "/" + jar;
 
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
+
+    OUString key = processLang(aGuard, Language) + "/" + jar;
 
     ZipFileTable::iterator it =
         m_aZipFileTable.emplace( key,Reference< XHierarchicalNameAccess 
>(nullptr) ).first;
@@ -808,7 +813,7 @@ Reference< XHierarchicalNameAccess > Databases::jarFile( 
std::u16string_view jar
             }
             else
             {
-                zipFile = getInstallPathAsURL() + key;
+                zipFile = m_aInstallDirectory + key;
             }
 
             Sequence< Any > aArguments( 2 );
@@ -1088,7 +1093,7 @@ void Databases::setActiveText( const OUString& Module,
 
 void Databases::setInstallPath( const OUString& aInstDir )
 {
-    osl::MutexGuard aGuard( m_aMutex );
+    std::unique_lock aGuard( m_aMutex );
 
     osl::FileBase::getFileURLFromSystemPath( aInstDir,m_aInstallDirectory );
         //TODO: check returned error code
diff --git a/xmlhelp/source/cxxhelp/provider/databases.hxx 
b/xmlhelp/source/cxxhelp/provider/databases.hxx
index 226de5254222..4ea43c4e8146 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.hxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.hxx
@@ -22,12 +22,12 @@
 #include <sal/config.h>
 
 #include <memory>
+#include <mutex>
 #include <string_view>
 #include <unordered_map>
 #include <unordered_set>
 #include <utility>
 #include <vector>
-#include <osl/mutex.hxx>
 #include <rtl/ustring.hxx>
 #include <rtl/strbuf.hxx>
 #include <o3tl/string_view.hxx>
@@ -205,7 +205,6 @@ namespace chelp {
         /**
          *  Maps a given language-locale combination to language or locale.
          */
-
         OUString processLang( const OUString& Language );
 
         void replaceName( OUString& oustring ) const;
@@ -219,8 +218,9 @@ namespace chelp {
             const css::uno::Reference< css::uno::XComponentContext >& xContext 
);
 
     private:
+        OUString processLang( std::unique_lock<std::mutex>& rGuard, const 
OUString& Language );
 
-        osl::Mutex                                               m_aMutex;
+        std::mutex                                               m_aMutex;
         css::uno::Reference< css::uno::XComponentContext >       m_xContext;
         css::uno::Reference< css::lang::XMultiComponentFactory > m_xSMgr;
         css::uno::Reference< css::ucb::XSimpleFileAccess3 >      m_xSFA;

Reply via email to