From f716f0bd85cabfa02cea1d092890a0dea67ef0e3 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 30 Jan 2017 10:04:07 -0800 Subject: Refcount CPDF_OCContext. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids explicit deletes through CPDF_RenderOptions holding pointers to it which may have been copy constructed. Ick. Change-Id: Ic044b66d13bd7c5eaa53de995373858081e115ec Reviewed-on: https://pdfium-review.googlesource.com/2451 Reviewed-by: dsinclair Reviewed-by: Nicolás Peña Commit-Queue: Tom Sepez --- core/fpdfdoc/cpdf_annotlist.cpp | 2 +- core/fpdfdoc/cpdf_occontext.h | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'core/fpdfdoc') diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp index 1ad6ab23a6..b1bc4c9ca9 100644 --- a/core/fpdfdoc/cpdf_annotlist.cpp +++ b/core/fpdfdoc/cpdf_annotlist.cpp @@ -126,7 +126,7 @@ void CPDF_AnnotList::DisplayPass(CPDF_Page* pPage, continue; if (pOptions) { - CPDF_OCContext* pOCContext = pOptions->m_pOCContext; + CFX_RetainPtr pOCContext = pOptions->m_pOCContext; CPDF_Dictionary* pAnnotDict = pAnnot->GetAnnotDict(); if (pOCContext && pAnnotDict && !pOCContext->CheckOCGVisible(pAnnotDict->GetDictFor("OC"))) { diff --git a/core/fpdfdoc/cpdf_occontext.h b/core/fpdfdoc/cpdf_occontext.h index 49bbd76d0c..ecdcfae31b 100644 --- a/core/fpdfdoc/cpdf_occontext.h +++ b/core/fpdfdoc/cpdf_occontext.h @@ -9,6 +9,7 @@ #include +#include "core/fxcrt/cfx_retain_ptr.h" #include "core/fxcrt/fx_string.h" class CPDF_Array; @@ -16,17 +17,20 @@ class CPDF_Dictionary; class CPDF_Document; class CPDF_PageObject; -class CPDF_OCContext { +class CPDF_OCContext : public CFX_Retainable { public: - enum UsageType { View = 0, Design, Print, Export }; + template + friend CFX_RetainPtr pdfium::MakeRetain(Args&&... args); - CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType); - ~CPDF_OCContext(); + enum UsageType { View = 0, Design, Print, Export }; bool CheckOCGVisible(const CPDF_Dictionary* pOCGDict); bool CheckObjectVisible(const CPDF_PageObject* pObj); private: + CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType); + ~CPDF_OCContext() override; + bool LoadOCGStateFromConfig(const CFX_ByteString& csConfig, const CPDF_Dictionary* pOCGDict) const; bool LoadOCGState(const CPDF_Dictionary* pOCGDict) const; -- cgit v1.2.3