summaryrefslogtreecommitdiff
path: root/xmlhelp
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-17 09:18:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-18 11:52:24 +0200
commit70c0c3b6157a869074ad7e9909b0e48d2da245e0 (patch)
tree888c1c613c5f86598625fd07523b22652e1be325 /xmlhelp
parenta8eb515599526b5b69647a842b2889b6f56de2c8 (diff)
loplugin:useuniqueptr in xmlhelp::Databases
Change-Id: Idaf73fd5d12badbee58861c6ca3b087c16946b9c Reviewed-on: https://gerrit.libreoffice.org/60615 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmlhelp')
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.cxx41
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.hxx6
2 files changed, 19 insertions, 28 deletions
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 2ab99629f3df..d71c62b4a95c 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -165,23 +165,14 @@ Databases::~Databases()
{
// unload the databases
- {
- // DatabasesTable
- for (auto& rDatabase : m_aDatabases)
- delete rDatabase.second;
- }
+ // DatabasesTable
+ m_aDatabases.clear();
- {
- // ModInfoTable
- for (auto& rModInfo : m_aModInfo)
- delete rModInfo.second;
- }
+ // ModInfoTable
+ m_aModInfo.clear();
- {
- // KeywordInfoTable
- for (auto& rKeywordInfo : m_aKeywordInfo)
- delete rKeywordInfo.second;
- }
+ // KeywordInfoTable
+ m_aKeywordInfo.clear();
}
OString Databases::getImageTheme()
@@ -390,14 +381,14 @@ StaticModuleInformation* Databases::getStaticInformationForModule( const OUStrin
lineBuffer[ pos++ ] = ch;
}
replaceName( title );
- it->second = new StaticModuleInformation( title,
+ it->second.reset(new StaticModuleInformation( title,
startid,
program,
- order );
+ order ));
}
}
- return it->second;
+ return it->second.get();
}
OUString Databases::processLang( const OUString& Language )
@@ -460,13 +451,13 @@ helpdatafileproxy::Hdf* Databases::getHelpDataFile( const OUString& Database,
key = *pExtensionPath + Language + dbFileName; // make unique, don't change language
std::pair< DatabasesTable::iterator,bool > aPair =
- m_aDatabases.emplace( key, reinterpret_cast<helpdatafileproxy::Hdf *>(0) );
+ m_aDatabases.emplace( key, nullptr);
DatabasesTable::iterator it = aPair.first;
if( aPair.second && ! it->second )
{
- helpdatafileproxy::Hdf* pHdf = nullptr;
+ std::unique_ptr<helpdatafileproxy::Hdf> pHdf;
OUString fileURL;
if( pExtensionPath )
@@ -482,13 +473,13 @@ helpdatafileproxy::Hdf* Databases::getHelpDataFile( const OUString& Database,
//fails for example when using long path names on Windows (starting with \\?\)
if( m_xSFA->exists( fileNameHDFHelp ) )
{
- pHdf = new helpdatafileproxy::Hdf( fileNameHDFHelp, m_xSFA );
+ pHdf.reset(new helpdatafileproxy::Hdf( fileNameHDFHelp, m_xSFA ));
}
- it->second = pHdf;
+ it->second = std::move(pHdf);
}
- return it->second;
+ return it->second.get();
}
Reference< XCollator >
@@ -775,10 +766,10 @@ KeywordInfo* Databases::getKeyword( const OUString& Database,
KeywordElementComparator aComparator( xCollator );
std::sort(aVector.begin(),aVector.end(),aComparator);
- it->second = new KeywordInfo( aVector );
+ it->second.reset(new KeywordInfo( aVector ));
}
- return it->second;
+ return it->second.get();
}
Reference< XHierarchicalNameAccess > Databases::jarFile( const OUString& jar,
diff --git a/xmlhelp/source/cxxhelp/provider/databases.hxx b/xmlhelp/source/cxxhelp/provider/databases.hxx
index ae3e5049af5c..3900e9918cdc 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.hxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.hxx
@@ -257,16 +257,16 @@ namespace chelp {
std::vector< OUString > m_avModules;
- typedef std::unordered_map< OUString,helpdatafileproxy::Hdf* > DatabasesTable;
+ typedef std::unordered_map< OUString, std::unique_ptr<helpdatafileproxy::Hdf> > DatabasesTable;
DatabasesTable m_aDatabases; // Language and module dependent databases
typedef std::unordered_map< OUString,OUString > LangSetTable;
LangSetTable m_aLangSet; // Mapping to of lang-country to lang
- typedef std::unordered_map< OUString,StaticModuleInformation* > ModInfoTable;
+ typedef std::unordered_map< OUString, std::unique_ptr<StaticModuleInformation> > ModInfoTable;
ModInfoTable m_aModInfo; // Module information
- typedef std::unordered_map< OUString,KeywordInfo* > KeywordInfoTable;
+ typedef std::unordered_map< OUString, std::unique_ptr<KeywordInfo> > KeywordInfoTable;
KeywordInfoTable m_aKeywordInfo; // Module information
typedef