Kaydet (Commit) 70c0c3b6 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in xmlhelp::Databases

Change-Id: Idaf73fd5d12badbee58861c6ca3b087c16946b9c
Reviewed-on: https://gerrit.libreoffice.org/60615
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst a8eb5155
......@@ -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,
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment