diff options
author | thestig <thestig@chromium.org> | 2016-05-31 05:46:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-31 05:46:52 -0700 |
commit | 4dce6d4689d464c3a8825a5d6aa790adfc9228ee (patch) | |
tree | 5be0b62c28735f57f53994a490581108cfdce829 /xfa/fxfa/app | |
parent | 8b3b3f59930eb29a80b3e83c0c724a50765b21f9 (diff) | |
download | pdfium-4dce6d4689d464c3a8825a5d6aa790adfc9228ee.tar.xz |
Fix a leak in CXFA_FontMgr.
Review-Url: https://codereview.chromium.org/2024713002
Diffstat (limited to 'xfa/fxfa/app')
-rw-r--r-- | xfa/fxfa/app/xfa_ffapp.cpp | 10 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fontmgr.cpp | 11 |
2 files changed, 12 insertions, 9 deletions
diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp index 6b7c06dc21..a26e2c99cf 100644 --- a/xfa/fxfa/app/xfa_ffapp.cpp +++ b/xfa/fxfa/app/xfa_ffapp.cpp @@ -7,6 +7,7 @@ #include "xfa/fxfa/include/xfa_ffapp.h" #include <algorithm> +#include <utility> #include "xfa/fgas/font/fgas_stdfontmgr.h" #include "xfa/fwl/core/cfwl_widgetmgr.h" @@ -131,15 +132,16 @@ CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, return pDoc; } -void CXFA_FFApp::SetDefaultFontMgr(CXFA_DefFontMgr* pFontMgr) { - if (!m_pFontMgr) { +void CXFA_FFApp::SetDefaultFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr) { + if (!m_pFontMgr) m_pFontMgr = new CXFA_FontMgr(); - } - m_pFontMgr->SetDefFontMgr(pFontMgr); + m_pFontMgr->SetDefFontMgr(std::move(pFontMgr)); } + CXFA_FontMgr* CXFA_FFApp::GetXFAFontMgr() { return m_pFontMgr; } + IFX_FontMgr* CXFA_FFApp::GetFDEFontMgr() { if (!m_pFDEFontMgr) { #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp index 9fec265a5a..ae1449876f 100644 --- a/xfa/fxfa/app/xfa_fontmgr.cpp +++ b/xfa/fxfa/app/xfa_fontmgr.cpp @@ -7,6 +7,7 @@ #include "xfa/fxfa/include/xfa_fontmgr.h" #include <algorithm> +#include <utility> #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" @@ -1997,7 +1998,7 @@ FX_BOOL CXFA_PDFFontMgr::GetCharWidth(IFX_Font* pFont, return TRUE; } -CXFA_FontMgr::CXFA_FontMgr() : m_pDefFontMgr(nullptr) {} +CXFA_FontMgr::CXFA_FontMgr() {} CXFA_FontMgr::~CXFA_FontMgr() {} @@ -2023,9 +2024,9 @@ IFX_Font* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc, if (pFont) return pFont; } - if (!pFont && m_pDefFontMgr) { + if (!pFont && m_pDefFontMgr) pFont = m_pDefFontMgr->GetFont(hDoc, wsFontFamily, dwFontStyles, wCodePage); - } + if (!pFont && pMgr) { pPDFFont = nullptr; pFont = pMgr->GetFont(wsEnglishName.AsStringC(), dwFontStyles, &pPDFFont, @@ -2056,6 +2057,6 @@ void CXFA_FontMgr::ReleaseDocFonts(CXFA_FFDoc* hDoc) { m_PDFFontMgrMap.erase(hDoc); } -void CXFA_FontMgr::SetDefFontMgr(CXFA_DefFontMgr* pFontMgr) { - m_pDefFontMgr = pFontMgr; +void CXFA_FontMgr::SetDefFontMgr(std::unique_ptr<CXFA_DefFontMgr> pFontMgr) { + m_pDefFontMgr = std::move(pFontMgr); } |