diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-13 14:34:15 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-08-15 08:40:07 +0200 |
commit | 40ab9800d3d19eee59571092a9872c8fe9af4e38 (patch) | |
tree | 5956486c551baf0f2913591d5e975e91e12f3c36 /vcl | |
parent | bac46d18a2a46024bb5cdf2ffb59ef6e0c028744 (diff) |
loplugin:useuniqueptr in PhysicalFontCollection
Change-Id: Id0a6a44848541968e9084a198366accda9c1149a
Reviewed-on: https://gerrit.libreoffice.org/59017
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/PhysicalFontCollection.hxx | 2 | ||||
-rw-r--r-- | vcl/source/font/PhysicalFontCollection.cxx | 24 |
2 files changed, 10 insertions, 16 deletions
diff --git a/vcl/inc/PhysicalFontCollection.hxx b/vcl/inc/PhysicalFontCollection.hxx index fd944a211631..46caab87c7c7 100644 --- a/vcl/inc/PhysicalFontCollection.hxx +++ b/vcl/inc/PhysicalFontCollection.hxx @@ -70,7 +70,7 @@ public: private: mutable bool mbMatchData; // true if matching attributes are initialized - typedef std::unordered_map<OUString, PhysicalFontFamily*> PhysicalFontFamilies; + typedef std::unordered_map<OUString, std::unique_ptr<PhysicalFontFamily>> PhysicalFontFamilies; PhysicalFontFamilies maPhysicalFontFamilies; ImplPreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx index 25edddd07b3d..7c5745a3a829 100644 --- a/vcl/source/font/PhysicalFontCollection.cxx +++ b/vcl/source/font/PhysicalFontCollection.cxx @@ -89,12 +89,6 @@ void PhysicalFontCollection::Clear() mnFallbackCount = -1; // clear all entries in the device font list - for (auto const& family : maPhysicalFontFamilies) - { - PhysicalFontFamily* pEntry = family.second; - delete pEntry; - } - maPhysicalFontFamilies.clear(); // match data must be recalculated too @@ -296,7 +290,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyBySearchName( cons if( it == maPhysicalFontFamilies.end() ) return nullptr; - PhysicalFontFamily* pFoundData = (*it).second; + PhysicalFontFamily* pFoundData = (*it).second.get(); return pFoundData; } @@ -311,12 +305,12 @@ PhysicalFontFamily *PhysicalFontCollection::FindOrCreateFontFamily( const OUStri PhysicalFontFamily* pFoundData = nullptr; if( it != maPhysicalFontFamilies.end() ) - pFoundData = (*it).second; + pFoundData = (*it).second.get(); if( !pFoundData ) { pFoundData = new PhysicalFontFamily( rFamilyName ); - maPhysicalFontFamilies[ rFamilyName ] = pFoundData; + maPhysicalFontFamilies[ rFamilyName ].reset(pFoundData); } return pFoundData; @@ -389,7 +383,7 @@ void PhysicalFontCollection::ImplInitMatchData() const for (auto const& family : maPhysicalFontFamilies) { const OUString& rSearchName = family.first; - PhysicalFontFamily* pEntry = family.second; + PhysicalFontFamily* pEntry = family.second.get(); pEntry->InitMatchData( rFontSubst, rSearchName ); } @@ -418,7 +412,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont for (auto const& family : maPhysicalFontFamilies) { - PhysicalFontFamily* pData = family.second; + PhysicalFontFamily* pData = family.second.get(); // Get all information about the matching font ImplFontAttrs nMatchType = pData->GetMatchType(); @@ -853,7 +847,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyOfDefaultFont() co for (auto const& family : maPhysicalFontFamilies) { - PhysicalFontFamily* pData = family.second; + PhysicalFontFamily* pData = family.second.get(); if( pData->GetMatchType() & ImplFontAttrs::Symbol ) continue; @@ -867,7 +861,7 @@ PhysicalFontFamily* PhysicalFontCollection::ImplFindFontFamilyOfDefaultFont() co // finding any font is better than finding no font at all auto it = maPhysicalFontFamilies.begin(); if( it != maPhysicalFontFamilies.end() ) - pFoundData = (*it).second; + pFoundData = (*it).second.get(); return pFoundData; } @@ -883,7 +877,7 @@ PhysicalFontCollection* PhysicalFontCollection::Clone() const for (auto const& family : maPhysicalFontFamilies) { - const PhysicalFontFamily* pFontFace = family.second; + const PhysicalFontFamily* pFontFace = family.second.get(); pFontFace->UpdateCloneFontList(*pClonedCollection); } @@ -896,7 +890,7 @@ std::unique_ptr<ImplDeviceFontList> PhysicalFontCollection::GetDeviceFontList() for (auto const& family : maPhysicalFontFamilies) { - const PhysicalFontFamily* pFontFamily = family.second; + const PhysicalFontFamily* pFontFamily = family.second.get(); pFontFamily->UpdateDevFontList( *pDeviceFontList ); } |