From ecd0ce5529ad6a577260bacaeff58a8bdf9c379f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 16 Jul 2018 08:42:50 +0200 Subject: loplugin:useuniqueptr in PrintFontManager Change-Id: I539e167b0b9d3523d50cbebc13227867c5f05bd5 Reviewed-on: https://gerrit.libreoffice.org/57515 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vcl/unx/generic/fontmanager/fontconfig.cxx | 2 +- vcl/unx/generic/fontmanager/fontmanager.cxx | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'vcl/unx/generic/fontmanager') diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx index 17629c09173a..a746061b8ebb 100644 --- a/vcl/unx/generic/fontmanager/fontconfig.cxx +++ b/vcl/unx/generic/fontmanager/fontconfig.cxx @@ -619,7 +619,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map& o // sort into known fonts fontID aFont = m_nNextFontID++; - m_aFonts[ aFont ] = xUpdate.release(); + m_aFonts[ aFont ] = std::move(xUpdate); m_aFontFileToFontID[ aBase ].insert( aFont ); nFonts++; SAL_INFO("vcl.fonts.detail", "inserted font " << family << " as fontID " << aFont); diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx index 150bec13a75b..a71fb7da6457 100644 --- a/vcl/unx/generic/fontmanager/fontmanager.cxx +++ b/vcl/unx/generic/fontmanager/fontmanager.cxx @@ -152,8 +152,6 @@ PrintFontManager::~PrintFontManager() { m_aFontInstallerTimer.Stop(); deinitFontconfig(); - for (auto const& font : m_aFonts) - delete font.second; } OString PrintFontManager::getDirectory( int nAtom ) const @@ -196,7 +194,7 @@ std::vector PrintFontManager::addFontFile( const OString& rFileName ) for (auto & font : aNewFonts) { fontID nFontId = m_nNextFontID++; - m_aFonts[nFontId] = font.release(); + m_aFonts[nFontId] = std::move(font); m_aFontFileToFontID[ aName ].insert( nFontId ); aFontIds.push_back(nFontId); } @@ -305,10 +303,10 @@ fontID PrintFontManager::findFontFileID( int nDirID, const OString& rFontFile, i for (auto const& elem : set_it->second) { - std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.find(elem); + auto it = m_aFonts.find(elem); if( it == m_aFonts.end() ) continue; - PrintFont* const pFont = (*it).second; + PrintFont* const pFont = (*it).second.get(); if (pFont->m_nDirectory == nDirID && pFont->m_aFontFile == rFontFile && pFont->m_nCollectionEntry == nFaceIndex) { @@ -331,10 +329,10 @@ std::vector PrintFontManager::findFontFileIDs( int nDirID, const OString for (auto const& elem : set_it->second) { - std::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.find(elem); + auto it = m_aFonts.find(elem); if( it == m_aFonts.end() ) continue; - PrintFont* const pFont = (*it).second; + PrintFont* const pFont = (*it).second.get(); if (pFont->m_nDirectory == nDirID && pFont->m_aFontFile == rFontFile) aIds.push_back(it->first); @@ -707,8 +705,6 @@ void PrintFontManager::initialize() // gtk-fontconfig-timestamp changes to reflect new font installed and // PrintFontManager::initialize called again { - for (auto const& font : m_aFonts) - delete font.second; m_nNextFontID = 1; m_aFonts.clear(); } -- cgit