[Libreoffice-commits] core.git: 2 commits - vcl/inc vcl/source vcl/unx
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Aug 15 06:40:33 UTC 2018
vcl/inc/PhysicalFontCollection.hxx | 2 +-
vcl/inc/unx/freetype_glyphcache.hxx | 2 +-
vcl/source/font/PhysicalFontCollection.cxx | 24 +++++++++---------------
vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 11 +++--------
4 files changed, 14 insertions(+), 25 deletions(-)
New commits:
commit 9467f10de690c622a210120e1963b2d755875a6b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 13 14:35:52 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 15 08:40:23 2018 +0200
loplugin:useuniqueptr in FreetypeManager
Change-Id: Idf8f843f2740bc20e6b0877b62dbfc778e31acd8
Reviewed-on: https://gerrit.libreoffice.org/59018
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx b/vcl/inc/unx/freetype_glyphcache.hxx
index 910aa2a70ae6..57c9f02df2ad 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -100,7 +100,7 @@ public:
FreetypeFont* CreateFont( const FontSelectPattern& );
private:
- typedef std::unordered_map<sal_IntPtr,FreetypeFontInfo*> FontList;
+ typedef std::unordered_map<sal_IntPtr, std::unique_ptr<FreetypeFontInfo>> FontList;
FontList maFontList;
sal_IntPtr mnMaxFontId;
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 32d6f9c8d10a..c747da4dae18 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -308,7 +308,7 @@ void FreetypeManager::AddFontFile( const OString& rNormalizedName,
FreetypeFontInfo* pFontInfo = new FreetypeFontInfo( rDevFontAttr,
rNormalizedName, nFaceNum, nFontId);
- maFontList[ nFontId ] = pFontInfo;
+ maFontList[ nFontId ].reset(pFontInfo);
if( mnMaxFontId < nFontId )
mnMaxFontId = nFontId;
}
@@ -317,18 +317,13 @@ void FreetypeManager::AnnounceFonts( PhysicalFontCollection* pToAdd ) const
{
for (auto const& font : maFontList)
{
- FreetypeFontInfo* pFreetypeFontInfo = font.second;
+ FreetypeFontInfo* pFreetypeFontInfo = font.second.get();
pFreetypeFontInfo->AnnounceFont( pToAdd );
}
}
void FreetypeManager::ClearFontList( )
{
- for (auto const& font : maFontList)
- {
- FreetypeFontInfo* pFreetypeFontInfo = font.second;
- delete pFreetypeFontInfo;
- }
maFontList.clear();
}
@@ -344,7 +339,7 @@ FreetypeFont* FreetypeManager::CreateFont( const FontSelectPattern& rFSD )
sal_IntPtr nFontId = pFontFace->GetFontId();
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)
return nullptr;
commit 40ab9800d3d19eee59571092a9872c8fe9af4e38
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Aug 13 14:34:15 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 15 08:40:07 2018 +0200
loplugin:useuniqueptr in PhysicalFontCollection
Change-Id: Id0a6a44848541968e9084a198366accda9c1149a
Reviewed-on: https://gerrit.libreoffice.org/59017
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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 );
}
More information about the Libreoffice-commits
mailing list