summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_document.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-09-14 23:19:51 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-14 23:19:51 +0000
commit3db36ef21df4187877f50212aec43ad865abb42c (patch)
treefb715766112eaca23362fbc1e74cf55568fc383f /core/fpdfapi/parser/cpdf_document.cpp
parent75560afd066b5a7e8f050232964bb013fa355f83 (diff)
downloadpdfium-3db36ef21df4187877f50212aec43ad865abb42c.tar.xz
Add CPDF_Document::StockFontClearer.
So CPDF_Document's dtor does not have to do any explicit cleanup. Change-Id: Iaec7d18f67422914542fc1dc5f3b1b5a9cf5ffc5 Reviewed-on: https://pdfium-review.googlesource.com/42551 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_document.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_document.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 233b98e3af..c82112e044 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -185,13 +185,10 @@ std::unique_ptr<CPDF_Dictionary> CalculateFontDesc(
CPDF_Document::CPDF_Document()
: m_pDocPage(pdfium::MakeUnique<CPDF_DocPageData>(this)),
- m_pDocRender(pdfium::MakeUnique<CPDF_DocRenderData>(this)) {}
+ m_pDocRender(pdfium::MakeUnique<CPDF_DocRenderData>(this)),
+ m_StockFontClearer(this) {}
-CPDF_Document::~CPDF_Document() {
- // Destroy the extension before doing any non-extension teardown.
- m_pExtension.reset();
- CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(this);
-}
+CPDF_Document::~CPDF_Document() = default;
std::unique_ptr<CPDF_Object> CPDF_Document::ParseIndirectObject(
uint32_t objnum) {
@@ -883,3 +880,10 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont) {
return LoadFont(pBaseDict);
}
#endif // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
+
+CPDF_Document::StockFontClearer::StockFontClearer(CPDF_Document* pDoc)
+ : m_pDoc(pDoc) {}
+
+CPDF_Document::StockFontClearer::~StockFontClearer() {
+ CPDF_ModuleMgr::Get()->GetPageModule()->ClearStockFont(m_pDoc.Get());
+}