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

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

Issue 2320213002: Reland of Fix leaked internal font (Closed)
Patch Set: rebase Created 4 years, 3 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
« no previous file with comments | « xfa/fgas/font/fgas_gefont.h ('k') | xfa/fgas/font/fgas_stdfontmgr.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fgas/font/fgas_gefont.cpp
diff --git a/xfa/fgas/font/fgas_gefont.cpp b/xfa/fgas/font/fgas_gefont.cpp
index d3be9dcb48a44ac17de9d0651c0a680b30112304..e386a0f2081548120729ce0001eb7424de1ad2a1 100644
--- a/xfa/fgas/font/fgas_gefont.cpp
+++ b/xfa/fgas/font/fgas_gefont.cpp
@@ -34,10 +34,21 @@ CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily,
}
// static
-CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExtFont,
+CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont,
IFGAS_FontMgr* pFontMgr) {
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
- if (!pFont->LoadFontInternal(pExtFont)) {
+ if (!pFont->LoadFontInternal(pExternalFont)) {
+ pFont->Release();
+ return nullptr;
+ }
+ return pFont;
+}
+
+// static
+CFGAS_GEFont* CFGAS_GEFont::LoadFont(std::unique_ptr<CFX_Font> pInternalFont,
+ IFGAS_FontMgr* pFontMgr) {
+ CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
+ if (!pFont->LoadFontInternal(std::move(pInternalFont))) {
pFont->Release();
return nullptr;
}
@@ -80,7 +91,7 @@ CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr)
m_pSrcFont(nullptr),
m_pFontMgr(pFontMgr),
m_iRefCount(1),
- m_bExtFont(FALSE),
+ m_bExternalFont(false),
m_pProvider(nullptr) {
}
@@ -94,7 +105,7 @@ CFGAS_GEFont::CFGAS_GEFont(CFGAS_GEFont* src, uint32_t dwFontStyles)
m_pSrcFont(src),
m_pFontMgr(src->m_pFontMgr),
m_iRefCount(1),
- m_bExtFont(FALSE),
+ m_bExternalFont(false),
m_pProvider(nullptr) {
ASSERT(m_pSrcFont->m_pFont);
m_pSrcFont->Retain();
@@ -120,7 +131,7 @@ CFGAS_GEFont::~CFGAS_GEFont() {
m_SubstFonts.RemoveAll();
m_FontMapper.clear();
- if (!m_bExtFont)
+ if (!m_bExternalFont)
delete m_pFont;
// If it is a shallow copy of another source font,
@@ -217,12 +228,22 @@ FX_BOOL CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream,
}
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-FX_BOOL CFGAS_GEFont::LoadFontInternal(CFX_Font* pExtFont) {
- if (m_pFont || !pExtFont) {
+FX_BOOL CFGAS_GEFont::LoadFontInternal(CFX_Font* pExternalFont) {
+ if (m_pFont || !pExternalFont)
return FALSE;
- }
- m_pFont = pExtFont;
- m_bExtFont = TRUE;
+
+ m_pFont = pExternalFont;
+ m_bExternalFont = true;
+ return InitFont();
+}
+
+FX_BOOL CFGAS_GEFont::LoadFontInternal(
+ std::unique_ptr<CFX_Font> pInternalFont) {
+ if (m_pFont || !pInternalFont)
+ return FALSE;
+
+ m_pFont = pInternalFont.release();
+ m_bExternalFont = false;
return InitFont();
}
« no previous file with comments | « xfa/fgas/font/fgas_gefont.h ('k') | xfa/fgas/font/fgas_stdfontmgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698