From 940967de0b588d3abb9cba5822ae5f5c5fe05017 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 18 May 2017 12:32:20 -0700 Subject: Use Unowned/Observed pointers between doc and FF onwership hierarchies. See the explanation in CPDFSDK_FormFillEnvironment.h Change-Id: I52feb25fb358831233a636e3ead5aa70e98c5baa Reviewed-on: https://pdfium-review.googlesource.com/5658 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 4 ++-- fpdfsdk/fpdfxfa/cpdfxfa_context.h | 3 ++- fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp | 6 ++++++ fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h | 7 ++++--- 4 files changed, 14 insertions(+), 6 deletions(-) (limited to 'fpdfsdk/fpdfxfa') diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp index 1345bc8a08..1032d49edc 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp @@ -58,7 +58,7 @@ CPDFXFA_Context::~CPDFXFA_Context() { // Once we're deleted the FormFillEnvironment will point at a bad underlying // doc so we need to reset it ... m_pFormFillEnv->ResetXFADocument(); - m_pFormFillEnv = nullptr; + m_pFormFillEnv.Reset(); } m_nLoadStatus = FXFA_LOADSTATUS_CLOSED; @@ -81,7 +81,7 @@ void CPDFXFA_Context::SetFormFillEnv( if (m_pXFADoc && m_pXFADoc->GetXFADoc()) m_pXFADoc->GetXFADoc()->ClearLayoutData(); - m_pFormFillEnv = pFormFillEnv; + m_pFormFillEnv.Reset(pFormFillEnv); } bool CPDFXFA_Context::LoadXFADoc() { diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h index 6d7e33b689..586e12d5be 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h @@ -10,6 +10,7 @@ #include #include +#include "core/fxcrt/cfx_observable.h" #include "core/fxcrt/cfx_unowned_ptr.h" #include "core/fxcrt/fx_system.h" #include "fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h" @@ -103,7 +104,7 @@ class CPDFXFA_Context : public IXFA_AppProvider { XFA_DocType m_iDocType; std::unique_ptr m_pPDFDoc; std::unique_ptr m_pXFADoc; - CFX_UnownedPtr m_pFormFillEnv; + CFX_Observable::ObservedPtr m_pFormFillEnv; CFX_UnownedPtr m_pXFADocView; std::unique_ptr m_pXFAApp; std::unique_ptr m_pRuntime; diff --git a/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp b/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp index c03ee45ac4..c7201c3fbd 100644 --- a/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp +++ b/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp @@ -29,6 +29,12 @@ class CFWL_FWLAdapterTimerInfo : public CFWL_TimerInfo { std::vector* CXFA_FWLAdapterTimerMgr::s_TimerArray = nullptr; +CXFA_FWLAdapterTimerMgr::CXFA_FWLAdapterTimerMgr( + CPDFSDK_FormFillEnvironment* pFormFillEnv) + : m_pFormFillEnv(pFormFillEnv) {} + +CXFA_FWLAdapterTimerMgr::~CXFA_FWLAdapterTimerMgr() {} + void CXFA_FWLAdapterTimerMgr::Start(CFWL_Timer* pTimer, uint32_t dwElapse, bool bImmediately, diff --git a/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h b/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h index fdb5635ff0..2b22c5fb75 100644 --- a/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h +++ b/fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h @@ -10,14 +10,15 @@ #include #include +#include "core/fxcrt/cfx_unowned_ptr.h" #include "fpdfsdk/fpdfxfa/cpdfxfa_context.h" #include "xfa/fwl/cfwl_timerinfo.h" #include "xfa/fwl/ifwl_adaptertimermgr.h" class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr { public: - explicit CXFA_FWLAdapterTimerMgr(CPDFSDK_FormFillEnvironment* pFormFillEnv) - : m_pFormFillEnv(pFormFillEnv) {} + explicit CXFA_FWLAdapterTimerMgr(CPDFSDK_FormFillEnvironment* pFormFillEnv); + ~CXFA_FWLAdapterTimerMgr(); void Start(CFWL_Timer* pTimer, uint32_t dwElapse, @@ -29,7 +30,7 @@ class CXFA_FWLAdapterTimerMgr : public IFWL_AdapterTimerMgr { static void TimerProc(int32_t idEvent); static std::vector* s_TimerArray; - CPDFSDK_FormFillEnvironment* const m_pFormFillEnv; + CFX_UnownedPtr const m_pFormFillEnv; }; #endif // FPDFSDK_FPDFXFA_CXFA_FWLADAPTERTIMERMGR_H_ -- cgit v1.2.3