Index: xfa/fgas/font/fgas_stdfontmgr.cpp |
diff --git a/xfa/fgas/font/fgas_stdfontmgr.cpp b/xfa/fgas/font/fgas_stdfontmgr.cpp |
index 20a520414c50f66ff1b631613b3910bed4c48b2a..ab7852e3108747e575e96b1c40666b066231aba0 100644 |
--- a/xfa/fgas/font/fgas_stdfontmgr.cpp |
+++ b/xfa/fgas/font/fgas_stdfontmgr.cpp |
@@ -17,8 +17,9 @@ |
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
-IFGAS_FontMgr* IFGAS_FontMgr::Create(FX_LPEnumAllFonts pEnumerator) { |
- return new CFGAS_StdFontMgrImp(pEnumerator); |
+std::unique_ptr<IFGAS_FontMgr> IFGAS_FontMgr::Create( |
+ FX_LPEnumAllFonts pEnumerator) { |
+ return std::unique_ptr<IFGAS_FontMgr>(new CFGAS_StdFontMgrImp(pEnumerator)); |
} |
CFGAS_StdFontMgrImp::CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator) |
@@ -47,10 +48,6 @@ CFGAS_StdFontMgrImp::~CFGAS_StdFontMgrImp() { |
m_Fonts[i]->Release(); |
} |
-void CFGAS_StdFontMgrImp::Release() { |
- delete this; |
-} |
- |
CFGAS_GEFont* CFGAS_StdFontMgrImp::GetDefFontByCodePage( |
uint16_t wCodePage, |
uint32_t dwFontStyles, |
@@ -564,20 +561,47 @@ IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) { |
return pAccess; |
} |
-IFGAS_FontMgr* IFGAS_FontMgr::Create(CFX_FontSourceEnum_File* pFontEnum) { |
+std::unique_ptr<IFGAS_FontMgr> IFGAS_FontMgr::Create( |
+ CFX_FontSourceEnum_File* pFontEnum) { |
if (!pFontEnum) |
return nullptr; |
std::unique_ptr<CFGAS_FontMgrImp> pFontMgr(new CFGAS_FontMgrImp(pFontEnum)); |
if (!pFontMgr->EnumFonts()) |
return nullptr; |
- return pFontMgr.release(); |
+ return std::move(pFontMgr); |
} |
CFGAS_FontMgrImp::CFGAS_FontMgrImp(CFX_FontSourceEnum_File* pFontEnum) |
: m_pFontSource(pFontEnum) {} |
-CFGAS_FontMgrImp::~CFGAS_FontMgrImp() {} |
+CFGAS_FontMgrImp::~CFGAS_FontMgrImp() { |
+ for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++) { |
+ delete m_InstalledFonts[i]; |
+ } |
+ FX_POSITION pos = m_Hash2CandidateList.GetStartPosition(); |
+ while (pos) { |
+ uint32_t dwHash; |
+ CFX_FontDescriptorInfos* pDescs; |
+ m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); |
+ delete pDescs; |
+ } |
+ pos = m_Hash2Fonts.GetStartPosition(); |
+ while (pos) { |
+ uint32_t dwHash; |
+ CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; |
+ m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); |
+ delete pFonts; |
+ } |
+ m_Hash2Fonts.RemoveAll(); |
+ pos = m_IFXFont2FileRead.GetStartPosition(); |
+ while (pos) { |
+ CFGAS_GEFont* pFont; |
+ IFX_FileRead* pFileRead; |
+ m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); |
+ pFileRead->Release(); |
+ } |
+} |
FX_BOOL CFGAS_FontMgrImp::EnumFontsFromFontMapper() { |
CFX_FontMapper* pFontMapper = |
@@ -634,35 +658,6 @@ FX_BOOL CFGAS_FontMgrImp::EnumFonts() { |
return EnumFontsFromFiles(); |
} |
-void CFGAS_FontMgrImp::Release() { |
- for (int32_t i = 0; i < m_InstalledFonts.GetSize(); i++) { |
- delete m_InstalledFonts[i]; |
- } |
- FX_POSITION pos = m_Hash2CandidateList.GetStartPosition(); |
- while (pos) { |
- uint32_t dwHash; |
- CFX_FontDescriptorInfos* pDescs; |
- m_Hash2CandidateList.GetNextAssoc(pos, dwHash, pDescs); |
- delete pDescs; |
- } |
- pos = m_Hash2Fonts.GetStartPosition(); |
- while (pos) { |
- uint32_t dwHash; |
- CFX_ArrayTemplate<CFGAS_GEFont*>* pFonts; |
- m_Hash2Fonts.GetNextAssoc(pos, dwHash, pFonts); |
- delete pFonts; |
- } |
- m_Hash2Fonts.RemoveAll(); |
- pos = m_IFXFont2FileRead.GetStartPosition(); |
- while (pos) { |
- CFGAS_GEFont* pFont; |
- IFX_FileRead* pFileRead; |
- m_IFXFont2FileRead.GetNextAssoc(pos, pFont, pFileRead); |
- pFileRead->Release(); |
- } |
- delete this; |
-} |
- |
CFGAS_GEFont* CFGAS_FontMgrImp::GetDefFontByCodePage( |
uint16_t wCodePage, |
uint32_t dwFontStyles, |