vcl/inc/PhysicalFontCollection.hxx | 3 ++- vcl/source/font/PhysicalFontCollection.cxx | 13 ++++++------- 2 files changed, 8 insertions(+), 8 deletions(-)
New commits: commit 96c1aad92b40a14d0d4af662e276b6967560ec20 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Mon Apr 23 14:32:12 2018 +0200 loplugin:useuniqueptr in PhysicalFontCollection Change-Id: I6b266ace50bb72ab807c3c938c51a83d5aceed0d Reviewed-on: https://gerrit.libreoffice.org/53356 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/vcl/inc/PhysicalFontCollection.hxx b/vcl/inc/PhysicalFontCollection.hxx index 1d5dbb908039..fd944a211631 100644 --- a/vcl/inc/PhysicalFontCollection.hxx +++ b/vcl/inc/PhysicalFontCollection.hxx @@ -24,6 +24,7 @@ #include "fontinstance.hxx" #include "PhysicalFontFamily.hxx" +#include <array> #define MAX_GLYPHFALLBACK 16 @@ -75,7 +76,7 @@ private: ImplPreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution ImplGlyphFallbackFontSubstitution* mpFallbackHook; // device specific glyph fallback substitution - mutable PhysicalFontFamily** mpFallbackList; + mutable std::unique_ptr<std::array<PhysicalFontFamily*,MAX_GLYPHFALLBACK>> mpFallbackList; mutable int mnFallbackCount; void ImplInitMatchData() const; diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx index 848fbdf06122..fcdef005dfdd 100644 --- a/vcl/source/font/PhysicalFontCollection.cxx +++ b/vcl/source/font/PhysicalFontCollection.cxx @@ -85,8 +85,7 @@ void PhysicalFontCollection::SetFallbackHook( ImplGlyphFallbackFontSubstitution* void PhysicalFontCollection::Clear() { // remove fallback lists - delete[] mpFallbackList; - mpFallbackList = nullptr; + mpFallbackList.reset(); mnFallbackCount = -1; // clear all entries in the device font list @@ -134,7 +133,7 @@ void PhysicalFontCollection::ImplInitGenericGlyphFallback() const bool bHasEudc = false; int nMaxLevel = 0; int nBestQuality = 0; - PhysicalFontFamily** pFallbackList = nullptr; + std::unique_ptr<std::array<PhysicalFontFamily*,MAX_GLYPHFALLBACK>> pFallbackList; for( const char** ppNames = &aGlyphFallbackList[0];; ++ppNames ) { @@ -165,16 +164,16 @@ void PhysicalFontCollection::ImplInitGenericGlyphFallback() const nBestQuality = pFallbackFont->GetMinQuality(); // store available glyph fallback fonts if( !pFallbackList ) - pFallbackList = new PhysicalFontFamily*[ MAX_GLYPHFALLBACK ]; + pFallbackList.reset(new std::array<PhysicalFontFamily*,MAX_GLYPHFALLBACK>); - pFallbackList[ nMaxLevel ] = pFallbackFont; + (*pFallbackList)[ nMaxLevel ] = pFallbackFont; if( !bHasEudc && !nMaxLevel ) bHasEudc = !strncmp( *ppNames, "eudc", 5 ); } } mnFallbackCount = nMaxLevel; - mpFallbackList = pFallbackList; + mpFallbackList = std::move(pFallbackList); } PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont( FontSelectPattern& rFontSelData, @@ -272,7 +271,7 @@ PhysicalFontFamily* PhysicalFontCollection::GetGlyphFallbackFont( FontSelectPatt // TODO: adjust nFallbackLevel by number of levels resolved by the fallback hook if( nFallbackLevel < mnFallbackCount ) - pFallbackData = mpFallbackList[ nFallbackLevel ]; + pFallbackData = (*mpFallbackList)[ nFallbackLevel ]; } return pFallbackData; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits