From c6ab97b5b5be7083c4929b7f08b33203a7f932da Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 14 Sep 2018 21:56:59 +0000 Subject: Use UnownedPtr in CFX_UnicodeEncoding. Change-Id: I410909be359a5b5bb0c90d42064144771183525e Reviewed-on: https://pdfium-review.googlesource.com/42461 Reviewed-by: Tom Sepez Commit-Queue: Lei Zhang --- core/fpdfapi/parser/cpdf_document.cpp | 2 ++ core/fxge/cfx_unicodeencoding.h | 4 +++- xfa/fgas/font/cfgas_gefont.cpp | 2 +- xfa/fgas/font/cfgas_gefont.h | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp index 7119e7649a..233b98e3af 100644 --- a/core/fpdfapi/parser/cpdf_document.cpp +++ b/core/fpdfapi/parser/cpdf_document.cpp @@ -188,6 +188,8 @@ CPDF_Document::CPDF_Document() m_pDocRender(pdfium::MakeUnique(this)) {} CPDF_Document::~CPDF_Document() { + // Destroy the extension before doing any non-extension teardown. + m_pExtension.reset(); CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this); } diff --git a/core/fxge/cfx_unicodeencoding.h b/core/fxge/cfx_unicodeencoding.h index f8bcff391f..57848c1267 100644 --- a/core/fxge/cfx_unicodeencoding.h +++ b/core/fxge/cfx_unicodeencoding.h @@ -9,6 +9,8 @@ #include +#include "core/fxcrt/unowned_ptr.h" + #ifdef PDF_ENABLE_XFA #define FXFM_ENC_TAG(a, b, c, d) \ (((uint32_t)(a) << 24) | ((uint32_t)(b) << 16) | ((uint32_t)(c) << 8) | \ @@ -39,7 +41,7 @@ class CFX_UnicodeEncoding { virtual uint32_t GlyphFromCharCode(uint32_t charcode); protected: - CFX_Font* m_pFont; // Unowned, not nullptr. + UnownedPtr const m_pFont; }; #endif // CORE_FXGE_CFX_UNICODEENCODING_H_ diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp index 0a57f54cdd..1c3d88beab 100644 --- a/xfa/fgas/font/cfgas_gefont.cpp +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -12,7 +12,6 @@ #include "core/fxcrt/fx_codepage.h" #include "core/fxge/cfx_font.h" #include "core/fxge/cfx_substfont.h" -#include "core/fxge/cfx_unicodeencoding.h" #include "core/fxge/cfx_unicodeencodingex.h" #include "third_party/base/ptr_util.h" #include "xfa/fgas/font/fgas_fontutils.h" @@ -57,6 +56,7 @@ RetainPtr CFGAS_GEFont::LoadFont( CFGAS_GEFont::CFGAS_GEFont(CFGAS_FontMgr* pFontMgr) : m_pFontMgr(pFontMgr) {} CFGAS_GEFont::~CFGAS_GEFont() { + m_pFontEncoding.reset(); // Has an UnownedPtr to |m_pFont|. if (!m_bExternalFont) delete m_pFont; } diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h index 2eadd5aaae..407a232595 100644 --- a/xfa/fgas/font/cfgas_gefont.h +++ b/xfa/fgas/font/cfgas_gefont.h @@ -18,7 +18,7 @@ #include "xfa/fgas/font/cfgas_fontmgr.h" #include "xfa/fgas/font/cfgas_pdffontmgr.h" -class CFX_UnicodeEncoding; +class CFX_UnicodeEncodingEx; class CFGAS_GEFont final : public Retainable { public: @@ -75,7 +75,7 @@ class CFGAS_GEFont final : public Retainable { uint32_t m_dwLogFontStyle = 0; CFX_Font* m_pFont = nullptr; CFGAS_FontMgr::ObservedPtr const m_pFontMgr; - std::unique_ptr m_pFontEncoding; + std::unique_ptr m_pFontEncoding; std::map m_CharWidthMap; std::map m_BBoxMap; std::vector> m_SubstFonts; -- cgit v1.2.3