summaryrefslogtreecommitdiff
path: root/xmlhelp
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-21 15:35:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-22 09:16:01 +0000
commit2c37a0ca31095165d05740a2ff4969f625b4a75b (patch)
tree86565412dc10615d177f208f45dd88890679685a /xmlhelp
parentc4f252035cd71f9a1b226e69095cc9f4e8f19f3e (diff)
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.grandin@collabora.co.uk>
Diffstat (limited to 'xmlhelp')
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.cxx39
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.hxx6
2 files changed, 25 insertions, 20 deletions
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;