diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-05-18 12:32:20 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-18 20:16:06 +0000 |
commit | 940967de0b588d3abb9cba5822ae5f5c5fe05017 (patch) | |
tree | 6c34432c66d716918efd1917075076dbd870084a /fpdfsdk/fpdfxfa | |
parent | 690d456ad54f021063dcc17fde27c7ba4d910717 (diff) | |
download | pdfium-940967de0b588d3abb9cba5822ae5f5c5fe05017.tar.xz |
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 <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfxfa')
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_context.h | 3 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.cpp | 6 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cxfa_fwladaptertimermgr.h | 7 |
4 files changed, 14 insertions, 6 deletions
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 <memory> #include <vector> +#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<CPDF_Document> m_pPDFDoc; std::unique_ptr<CXFA_FFDoc> m_pXFADoc; - CFX_UnownedPtr<CPDFSDK_FormFillEnvironment> m_pFormFillEnv; + CFX_Observable<CPDFSDK_FormFillEnvironment>::ObservedPtr m_pFormFillEnv; CFX_UnownedPtr<CXFA_FFDocView> m_pXFADocView; std::unique_ptr<CXFA_FFApp> m_pXFAApp; std::unique_ptr<CJS_Runtime> 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<CFWL_TimerInfo*>* 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 <memory> #include <vector> +#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<CFWL_TimerInfo*>* s_TimerArray; - CPDFSDK_FormFillEnvironment* const m_pFormFillEnv; + CFX_UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv; }; #endif // FPDFSDK_FPDFXFA_CXFA_FWLADAPTERTIMERMGR_H_ |