From 2116105b7d0545eb353264d4b42420cf51af5195 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 5 Oct 2016 15:46:15 -0700 Subject: Remove ownership of CPDFSDK_Document from CPDFXFA_Document This CL updates CPDFXFA_Document so it never owns the CPDFSDK_Document. The CPDFSDK_Document is now always owned by the CPDFXFA_Environment. This also cleans up the strange need to reverse the order of document and form destruction when using XFA. Review-Url: https://codereview.chromium.org/2397473006 --- fpdfsdk/cpdfsdk_environment.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'fpdfsdk/cpdfsdk_environment.h') diff --git a/fpdfsdk/cpdfsdk_environment.h b/fpdfsdk/cpdfsdk_environment.h index 9943d38c67..bed757c2ba 100644 --- a/fpdfsdk/cpdfsdk_environment.h +++ b/fpdfsdk/cpdfsdk_environment.h @@ -146,8 +146,7 @@ class CPDFSDK_Environment final { void JS_docgotoPage(int nPageNum); FX_BOOL IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; } - void SetSDKDocument(CPDFSDK_Document* pFXDoc) { m_pSDKDoc = pFXDoc; } - CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc; } + CPDFSDK_Document* GetSDKDocument() const { return m_pSDKDoc.get(); } UnderlyingDocumentType* GetUnderlyingDocument() const { return m_pUnderlyingDoc; } @@ -166,10 +165,7 @@ class CPDFSDK_Environment final { std::unique_ptr m_pActionHandler; std::unique_ptr m_pJSRuntime; FPDF_FORMFILLINFO* const m_pInfo; - // Ownership of |m_pSDKDoc| depends on if this is XFA. If we're in XFA then - // the object is owned by the CPDFXFA_Document. In non-xfa then we own - // the pointer. - CPDFSDK_Document* m_pSDKDoc; + std::unique_ptr m_pSDKDoc; UnderlyingDocumentType* const m_pUnderlyingDoc; std::unique_ptr m_pFormFiller; std::unique_ptr m_pSysHandler; -- cgit v1.2.3