From cf89faf5da79e186ad354b320ea3e562a2956c37 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 25 Apr 2017 14:17:33 -0700 Subject: Use unique_ptr for CFX_GEModule::m_pFontCache. Change-Id: I656e8028001fadd7869a08593f10b0b8e25fe01c Reviewed-on: https://pdfium-review.googlesource.com/4497 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- core/fxge/cfx_gemodule.h | 2 +- core/fxge/ge/cfx_gemodule.cpp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/fxge/cfx_gemodule.h b/core/fxge/cfx_gemodule.h index 587ec89e59..4dfa413437 100644 --- a/core/fxge/cfx_gemodule.h +++ b/core/fxge/cfx_gemodule.h @@ -40,7 +40,7 @@ class CFX_GEModule { void DestroyPlatform(); uint8_t m_GammaValue[256]; - CFX_FontCache* m_pFontCache; + std::unique_ptr m_pFontCache; std::unique_ptr m_pFontMgr; CCodec_ModuleMgr* m_pCodecModule; void* m_pPlatformData; diff --git a/core/fxge/ge/cfx_gemodule.cpp b/core/fxge/ge/cfx_gemodule.cpp index 790b670e4f..125758b6ad 100644 --- a/core/fxge/ge/cfx_gemodule.cpp +++ b/core/fxge/ge/cfx_gemodule.cpp @@ -10,6 +10,7 @@ #include "core/fxge/cfx_fontmgr.h" #include "core/fxge/ge/cfx_folderfontinfo.h" #include "core/fxge/ge/fx_text_int.h" +#include "third_party/base/ptr_util.h" namespace { @@ -19,14 +20,12 @@ CFX_GEModule* g_pGEModule = nullptr; CFX_GEModule::CFX_GEModule() : m_FTLibrary(nullptr), - m_pFontCache(nullptr), m_pFontMgr(new CFX_FontMgr), m_pCodecModule(nullptr), m_pPlatformData(nullptr), m_pUserFontPaths(nullptr) {} CFX_GEModule::~CFX_GEModule() { - delete m_pFontCache; DestroyPlatform(); } @@ -55,8 +54,8 @@ void CFX_GEModule::Init(const char** userFontPaths, CFX_FontCache* CFX_GEModule::GetFontCache() { if (!m_pFontCache) - m_pFontCache = new CFX_FontCache(); - return m_pFontCache; + m_pFontCache = pdfium::MakeUnique(); + return m_pFontCache.get(); } void CFX_GEModule::SetTextGamma(float gammaValue) { -- cgit v1.2.3