Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(623)

Unified Diff: xfa/fgas/font/cfgas_fontmgr.cpp

Issue 2562563002: Properly ref count IFX_FileAccess. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« core/fxcrt/fx_extension.cpp ('K') | « xfa/fgas/font/cfgas_fontmgr.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fgas/font/cfgas_fontmgr.cpp
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 060dd95b48aff8aade8d7c94a1bd5d65d3844cf3..d7e7e8ed84a138a33cea7ab6f1ecacfdbca26991 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) {
dsinclair 2016/12/07 23:05:03 Can this be a * instead of an &?
Tom Sepez 2016/12/07 23:26:55 It could, but this goes far beyond this -- the FX
+ 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;
}
« core/fxcrt/fx_extension.cpp ('K') | « xfa/fgas/font/cfgas_fontmgr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698