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

Unified Diff: xfa/fwl/theme/cfwl_widgettp.cpp

Issue 2609423003: Properly ref-count CFGAS_GEFont with CFX_RetainPtr. (Closed)
Patch Set: comments Created 3 years, 11 months 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
Index: xfa/fwl/theme/cfwl_widgettp.cpp
diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp
index 395571c2c404bb57a63a10a69a3ac0ab12fc5fd7..a0d6b4c54d9ee3dd2e8439b394c435a78296089f 100644
--- a/xfa/fwl/theme/cfwl_widgettp.cpp
+++ b/xfa/fwl/theme/cfwl_widgettp.cpp
@@ -298,8 +298,8 @@ bool CFWL_FontData::LoadFont(const CFX_WideStringC& wsFontFamily,
m_pFontMgr = CFGAS_FontMgr::Create(m_pFontSource.get());
#endif
}
- m_pFont.reset(CFGAS_GEFont::LoadFont(wsFontFamily.c_str(), dwFontStyles,
- dwCodePage, m_pFontMgr.get()));
+ m_pFont = CFGAS_GEFont::LoadFont(wsFontFamily.c_str(), dwFontStyles,
+ dwCodePage, m_pFontMgr.get());
return !!m_pFont;
}
@@ -319,16 +319,18 @@ CFWL_FontManager::CFWL_FontManager() {}
CFWL_FontManager::~CFWL_FontManager() {}
-CFGAS_GEFont* CFWL_FontManager::FindFont(const CFX_WideStringC& wsFontFamily,
- uint32_t dwFontStyles,
- uint16_t wCodePage) {
+CFX_RetainPtr<CFGAS_GEFont> CFWL_FontManager::FindFont(
+ const CFX_WideStringC& wsFontFamily,
+ uint32_t dwFontStyles,
+ uint16_t wCodePage) {
for (const auto& pData : m_FontsArray) {
if (pData->Equal(wsFontFamily, dwFontStyles, wCodePage))
return pData->GetFont();
}
- std::unique_ptr<CFWL_FontData> pFontData(new CFWL_FontData);
+ auto pFontData = pdfium::MakeUnique<CFWL_FontData>();
if (!pFontData->LoadFont(wsFontFamily, dwFontStyles, wCodePage))
return nullptr;
+
m_FontsArray.push_back(std::move(pFontData));
return m_FontsArray.back()->GetFont();
}

Powered by Google App Engine
This is Rietveld 408576698