Kaydet (Commit) 9467f10d authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in FreetypeManager

Change-Id: Idf8f843f2740bc20e6b0877b62dbfc778e31acd8
Reviewed-on: https://gerrit.libreoffice.org/59018
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 40ab9800
...@@ -100,7 +100,7 @@ public: ...@@ -100,7 +100,7 @@ public:
FreetypeFont* CreateFont( const FontSelectPattern& ); FreetypeFont* CreateFont( const FontSelectPattern& );
private: private:
typedef std::unordered_map<sal_IntPtr,FreetypeFontInfo*> FontList; typedef std::unordered_map<sal_IntPtr, std::unique_ptr<FreetypeFontInfo>> FontList;
FontList maFontList; FontList maFontList;
sal_IntPtr mnMaxFontId; sal_IntPtr mnMaxFontId;
......
...@@ -308,7 +308,7 @@ void FreetypeManager::AddFontFile( const OString& rNormalizedName, ...@@ -308,7 +308,7 @@ void FreetypeManager::AddFontFile( const OString& rNormalizedName,
FreetypeFontInfo* pFontInfo = new FreetypeFontInfo( rDevFontAttr, FreetypeFontInfo* pFontInfo = new FreetypeFontInfo( rDevFontAttr,
rNormalizedName, nFaceNum, nFontId); rNormalizedName, nFaceNum, nFontId);
maFontList[ nFontId ] = pFontInfo; maFontList[ nFontId ].reset(pFontInfo);
if( mnMaxFontId < nFontId ) if( mnMaxFontId < nFontId )
mnMaxFontId = nFontId; mnMaxFontId = nFontId;
} }
...@@ -317,18 +317,13 @@ void FreetypeManager::AnnounceFonts( PhysicalFontCollection* pToAdd ) const ...@@ -317,18 +317,13 @@ void FreetypeManager::AnnounceFonts( PhysicalFontCollection* pToAdd ) const
{ {
for (auto const& font : maFontList) for (auto const& font : maFontList)
{ {
FreetypeFontInfo* pFreetypeFontInfo = font.second; FreetypeFontInfo* pFreetypeFontInfo = font.second.get();
pFreetypeFontInfo->AnnounceFont( pToAdd ); pFreetypeFontInfo->AnnounceFont( pToAdd );
} }
} }
void FreetypeManager::ClearFontList( ) void FreetypeManager::ClearFontList( )
{ {
for (auto const& font : maFontList)
{
FreetypeFontInfo* pFreetypeFontInfo = font.second;
delete pFreetypeFontInfo;
}
maFontList.clear(); maFontList.clear();
} }
...@@ -344,7 +339,7 @@ FreetypeFont* FreetypeManager::CreateFont( const FontSelectPattern& rFSD ) ...@@ -344,7 +339,7 @@ FreetypeFont* FreetypeManager::CreateFont( const FontSelectPattern& rFSD )
sal_IntPtr nFontId = pFontFace->GetFontId(); sal_IntPtr nFontId = pFontFace->GetFontId();
FontList::iterator it = maFontList.find(nFontId); FontList::iterator it = maFontList.find(nFontId);
FreetypeFontInfo* pFontInfo = it != maFontList.end() ? it->second : nullptr; FreetypeFontInfo* pFontInfo = it != maFontList.end() ? it->second.get() : nullptr;
if (!pFontInfo) if (!pFontInfo)
return nullptr; return nullptr;
......
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