From cedaa557316a3f5c436814e69d67f19795f471d7 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 24 Aug 2016 11:12:19 -0700 Subject: Flip document and parser ownership This Cl switches the ownership between the parser and the document. Previously the parser owned the document and we'd jump through hoops during cleanup to delete the right object. This Cl flips the ownership so the document owns the parser and simplifies the cleanup logic where needed. BUG=pdfium:565 Review-Url: https://codereview.chromium.org/2275773003 --- fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'fpdfsdk/fpdfxfa/include') diff --git a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h index ed4c8727fc..c83c770f97 100644 --- a/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h +++ b/fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h @@ -27,12 +27,13 @@ class CXFA_FFDocHandler; class CPDFXFA_Document : public IXFA_DocProvider { public: - CPDFXFA_Document(CPDF_Document* pPDFDoc, CPDFXFA_App* pProvider); + CPDFXFA_Document(std::unique_ptr pPDFDoc, + CPDFXFA_App* pProvider); ~CPDFXFA_Document() override; FX_BOOL LoadXFADoc(); CPDFXFA_App* GetApp() { return m_pApp; } - CPDF_Document* GetPDFDoc() { return m_pPDFDoc; } + CPDF_Document* GetPDFDoc() { return m_pPDFDoc.get(); } CXFA_FFDoc* GetXFADoc() { return m_pXFADoc.get(); } CXFA_FFDocView* GetXFADocView() { return m_pXFADocView; } @@ -200,7 +201,10 @@ class CPDFXFA_Document : public IXFA_DocProvider { } int m_iDocType; - CPDF_Document* m_pPDFDoc; + + // |m_pSDKDoc| has to be released before |m_pPDFDoc| since it needs to access + // it to kill focused annotations. + std::unique_ptr m_pPDFDoc; std::unique_ptr m_pSDKDoc; std::unique_ptr m_pXFADoc; CXFA_FFDocView* m_pXFADocView; // not owned. -- cgit v1.2.3