diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-16 08:42:50 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-07-17 08:39:00 +0200 |
commit | ecd0ce5529ad6a577260bacaeff58a8bdf9c379f (patch) | |
tree | e4c1d861393074cc423172f47798f3c802404edf | |
parent | 60c08199f215ff7db335a692cbbcb72d1ac582d1 (diff) |
loplugin:useuniqueptr in PrintFontManager
Change-Id: I539e167b0b9d3523d50cbebc13227867c5f05bd5
Reviewed-on: https://gerrit.libreoffice.org/57515
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | vcl/inc/unx/fontmanager.hxx | 7 | ||||
-rw-r--r-- | vcl/unx/generic/fontmanager/fontconfig.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/fontmanager/fontmanager.cxx | 14 |
3 files changed, 9 insertions, 14 deletions
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx index 8b2c70c25000..fcaf801018c4 100644 --- a/vcl/inc/unx/fontmanager.hxx +++ b/vcl/inc/unx/fontmanager.hxx @@ -136,7 +136,7 @@ class VCL_PLUGIN_PUBLIC PrintFontManager }; fontID m_nNextFontID; - std::unordered_map< fontID, PrintFont* > m_aFonts; + std::unordered_map< fontID, std::unique_ptr<PrintFont> > m_aFonts; // for speeding up findFontFileID std::unordered_map< OString, std::set< fontID > > m_aFontFileToFontID; @@ -163,9 +163,8 @@ class VCL_PLUGIN_PUBLIC PrintFontManager PrintFont* getFont( fontID nID ) const { - std::unordered_map< fontID, PrintFont* >::const_iterator it; - it = m_aFonts.find( nID ); - return it == m_aFonts.end() ? nullptr : it->second; + auto it = m_aFonts.find( nID ); + return it == m_aFonts.end() ? nullptr : it->second.get(); } static void fillPrintFontInfo(PrintFont* pFont, FastPrintFontInfo& rInfo); void fillPrintFontInfo( PrintFont* pFont, PrintFontInfo& rInfo ) const; 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<OString, int>& 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<fontID> 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<fontID> 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(); } |