diff options
author | tsepez <tsepez@chromium.org> | 2016-12-07 15:28:14 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-12-07 15:28:14 -0800 |
commit | a9d29df6a774737a661d0f37f6b8aa5cba179c06 (patch) | |
tree | 0bd11a3575f9459163247de93db3fa375a44e98a /xfa/fgas/font/cfgas_fontmgr.cpp | |
parent | cd5e12a9ea397b48056643a7b65126395eec3174 (diff) | |
download | pdfium-a9d29df6a774737a661d0f37f6b8aa5cba179c06.tar.xz |
Properly ref count IFX_FileAccess.
Review-Url: https://codereview.chromium.org/2562563002
Diffstat (limited to 'xfa/fgas/font/cfgas_fontmgr.cpp')
-rw-r--r-- | xfa/fgas/font/cfgas_fontmgr.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index 060dd95b48..d7e7e8ed84 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -566,10 +566,12 @@ FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { return (FX_POSITION)-1; } -IFX_FileAccess* CFX_FontSourceEnum_File::GetNext(FX_POSITION& pos) { - IFX_FileAccess* pAccess = IFX_FileAccess::CreateDefault(m_wsNext.AsStringC()); +CFX_RetainPtr<IFX_FileAccess> CFX_FontSourceEnum_File::GetNext( + FX_POSITION& pos) { + CFX_RetainPtr<IFX_FileAccess> pAccess = + IFX_FileAccess::CreateDefault(m_wsNext.AsStringC()); m_wsNext = GetNextFile().UTF8Decode(); - pos = m_wsNext.GetLength() != 0 ? pAccess : nullptr; + pos = m_wsNext.GetLength() != 0 ? pAccess.Get() : nullptr; return pAccess; } @@ -636,17 +638,12 @@ bool CFGAS_FontMgr::EnumFontsFromFontMapper() { bool CFGAS_FontMgr::EnumFontsFromFiles() { CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); FX_POSITION pos = m_pFontSource->GetStartPosition(); - IFX_FileAccess* pFontSource = nullptr; - CFX_RetainPtr<IFX_SeekableReadStream> pFontStream; while (pos) { - pFontSource = m_pFontSource->GetNext(pos); - pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); - if (!pFontStream) { - pFontSource->Release(); - continue; - } - RegisterFaces(pFontStream, nullptr); - pFontSource->Release(); + CFX_RetainPtr<IFX_FileAccess> pFontSource = m_pFontSource->GetNext(pos); + CFX_RetainPtr<IFX_SeekableReadStream> pFontStream = + pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); + if (pFontStream) + RegisterFaces(pFontStream, nullptr); } return m_InstalledFonts.GetSize() != 0; } |